<template>
  <div>
    <Drawer
      placement="left"
      v-model="drawerShow"
      :closable="false"
      :mask="false"
      :mask-closable="false"
      :transfer="false"
      width="320"
      :inner="true"
      id="leftDrawer"
    >
      <!-- <img
        src="@/assets/icons/shrink.png"
        alt="X"
        id="closeBtn"
        class="iconBtn"
        @click="hideDrawer"
      /> -->
      <div id="leftInner">
        <div class="topBtnGroup">
          <Button @click="settingChange">设置</Button>
          <Button @click="dataTreeChange">数据目录</Button>
          <img
            src="@/assets/icons/shrink.png"
            alt="X"
            class="iconBtn"
            @click="hideDrawer"
          />
        </div>
        <!-- 设置 -->
        <div v-show="dataSettingShow">
          <!-- 任务描述 -->
          <div class="tab-header">
            <img
              src="@/assets/icons/emergencyIcons/emergencyMonitor/taskIcon.png"
              alt=""
              class="iconBtn"
            />

            <span class="tab-title">任务描述</span>
          </div>
          <div id="taskDescription">
            <div>
              <span>事件名称</span>
              <Input v-model="taskName" disabled></Input>
            </div>

            <div>
              <span>时间</span>
              <Input v-model="taskTime" disabled></Input>
            </div>

            <div>
              <span>地点</span>
              <Input v-model="TaskAddress" disabled></Input>
            </div>

            <div>
              <span>灾种</span>
              <Input v-model="TaskDisasterType" disabled></Input>
            </div>
          </div>
          <!-- 空间区划 -->
          <div id="spatialRegion">
            <div class="tab-header">
              <img
                src="@/assets/icons/emergencyIcons/emergencyMonitor/areaIcon.png"
                alt=""
                class="iconBtn"
              />

              <span class="tab-title">空间范围</span>
            </div>
            <!-- <CRow class="task-monitorTable-row"> -->
            <Tabs>
              <TabPane label="区划" name="name1">
                <div class="regionBlock">
                  <Cascader
                    :data="regionCascader"
                    :disabled="this.TaskAddress == '其他' ? true : false"
                    change-on-select
                    filterable
                    class="regionCas"
                    :load-data="loadRegionData"
                    @on-change="regionChangeEvent"
                    transfer
                  ></Cascader>
                  <CButton
                    color="info"
                    class="system-btn-style"
                    @click="addAreaResult('region')"
                    >添加</CButton
                  >
                </div>
              </TabPane>
              <TabPane label="矢量范围" name="name2">
                <div class="regionBlock">
                  <Input placeholder="添加shp矢量文件" />
                  <CButton color="info" class="system-btn-style" @click="selecrShpPath"
                    >选择</CButton
                  >
                </div></TabPane
              >
              <TabPane label="自定义" name="name3">
                <!-- <div class="regionBlock">
                  <CButton
                    color="info"
                    class="system-btn-style"
                    @click="drawRectangle"
                    >矩形</CButton
                  >
                  <CButton
                    color="info"
                    class="system-btn-style"
                    style="width: 70px"
                    @click="drawPloy"
                    >多边形</CButton
                  >
                </div> -->
                <div class="regionBlock">
                  <Select v-model="customerArea" transfer>
                    <Option
                      v-for="item in customerRegionList"
                      :value="item.id"
                      :key="item.regionName"
                      transfer
                      placeholder="请选择区域"
                    >
                      {{ item.regionName }}
                    </Option>
                  </Select>
                  <CButton
                    color="info"
                    class="system-btn-style"
                    @click="addAreaResult('custom')"
                    >添加</CButton
                  >
                </div>
              </TabPane>
            </Tabs>
          </div>
          <!-- 区域结果 -->
          <div id="regionResult">
            <div class="tab-header">
              <img
                src="@/assets/icons/emergencyIcons/emergencyMonitor/manageIcon.png"
                alt=""
                class="iconBtn"
              />

              <span class="tab-title">区域结果</span>

              <img
                src="@/assets/icons/delete.svg"
                class="iconBtn delete"
                alt="delete"
                @click="regionDel"
              />
            </div>
            <div class="spatial-region-row">
              <select multiple class="batchSelect">
                <option
                  v-for="(itemsli, index) in regionResultList"
                  :key="index"
                  :title="itemsli"
                  :value="itemsli.value"
                  @click="onSelectOption(itemsli, index)"
                >
                  {{ itemsli }}
                </option>
              </select>
            </div>
          </div>
          <!-- 卫星传感器 -->
          <div id="sensorChoose">
            <div class="tab-header">
              <span class="tab-title">卫星传感器选择</span>
              <CButton color="info" class="system-btn-style" @click="selectAddInfo"
                >选择</CButton
              >
            </div>

            <div id="samePeriod">
              <div>
                <span>卫星</span>
                <Input
                  v-model="satellites"
                  placeholder="请点击“选择”勾选卫星信息"
                  disabled
                  :title="satellites"
                ></Input>
              </div>

              <div>
                <span>传感器</span>
                <Input
                  v-model="sensors"
                  placeholder="请点击“选择”勾选传感器信息"
                  disabled
                  :title="sensors"
                ></Input>
              </div>
            </div>
          </div>
          <!-- 产品级别 -->
          <div id="productLevel">
            <div class="tab-header">
              <span class="tab-title">产品级别</span>
            </div>
            <Select v-model="productLevel">
              <Option
                v-for="item in productLevelList"
                :value="item"
                :key="item"
                placeholder="请选择产品级别"
              >
                {{ item }}
              </Option>
            </Select>
          </div>
          <!-- 保存 取消 -->
          <div class="formBtnGroup">
            <CButton color="info" class="system-btn-style" @click="saveEmergencyTask"
              >保存</CButton
            >
            <CButton color="info" class="system-btn-style" @click="ProductProductionBtn"
              >取消</CButton
            >
          </div>
        </div>
        <!-- 数据目录树 -->
        <div v-show="dataTreeShow" id="treeData">
          <div style="display: flex">
            <span style="margin-top: 5px">&nbsp;&nbsp;区域&nbsp;&nbsp;</span>
            <Select
              placeholder="请选择区域.."
              transfer
              clearable
              v-model="regionSelected"
              style="width: 200px; margin-left: 20px"
            >
              <Option
                v-for="item in regionResultIDList"
                :value="item.regionID"
                :key="item.regionName"
              >
                {{ item.regionName }}
              </Option>
            </Select>
          </div>
          <div style="display: flex; margin-top: 5px">
            <span style="margin-top: 5px">&nbsp;&nbsp;卫星&nbsp;&nbsp;</span>
            <Select
              placeholder="请选择卫星.."
              transfer
              clearable
              v-model="satelliteSelected"
              style="width: 200px; margin-left: 20px"
            >
              <Option v-for="item in satelliteResultNameList" :value="item" :key="item">
                {{ item }}
              </Option>
            </Select>
          </div>
          <div style="display: flex; margin-top: 5px">
            <span style="margin-top: 8px">关键字</span>
            <Input
              search
              enter-button
              placeholder="请输入关键字..."
              @on-search="keySearch"
              style="width: 200px; margin-left: 21px"
            />
          </div>
          <div style="height: 750px">
            <Tree
              :data="dataTreeList"
              :render="renderContent"
              show-checkbox
              ref="tree"
              :check-strictly="true"
              @on-check-change="getTreeNodeInfo"
              @on-contextmenu="handleContextMenu"
            >
              <!-- :check-strictly="true" -->
              <!-- check-strictly -->
              <template slot="contextMenu">
                <DropdownItem
                  v-if="this.currentTreeNode && this.currentTreeNode.path"
                  @click.native="metadataView"
                >
                  <span class="crimson-text">元数据查看</span>
                </DropdownItem>
                <!-- L1级影像缩放到图层 -->
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.level.substr(0, 2) == 'L1'&&
                    this.currentTreeNode.title.substr(-4) != '.shp'
                  "
                  @click.native="fixScaleMapL1A"
                >
                  <span class="crimson-text">缩放到图层</span>
                </DropdownItem>
                <!-- L2级影像缩放到图层 -->
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.level.substr(0, 2) == 'L2' &&
                    this.currentTreeNode.title.substr(-4) != '.shp'
                  "
                  @click.native="fixScaleMapL1A"
                >
                  <span class="crimson-text">缩放到图层</span>
                </DropdownItem>
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.level.substr(0, 2) != 'L1' &&
                    this.currentTreeNode.level.substr(0, 2) != 'L2' &&
                    this.currentTreeNode.title.substr(-4) != '.shp'
                  "
                  @click.native="fixScaleMapTile"
                >
                  <span class="crimson-text">缩放到图层</span>
                </DropdownItem>
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.title.substr(-4) === '.shp'
                  "
                  @click.native="fixScaleMapShp"
                >
                  <span class="crimson-text">缩放到图层</span>
                </DropdownItem>
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.path &&
                    this.currentTreeNode.level != 'L1A'
                  "
                  @click.native="styleOfTreeData"
                >
                  <span class="crimson-text">样式设置</span>
                </DropdownItem>
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.path &&
                    this.currentTreeNode.title.substr(-4) === '.shp'
                  "
                  @click.native="shpColorView"
                >
                  <span class="crimson-text">颜色设置</span>
                </DropdownItem>
                <DropdownItem
                  v-if="
                    this.currentTreeNode &&
                    this.currentTreeNode.checked &&
                    this.currentTreeNode.title.substr(-4) != '.shp'
                  "
                  @click.native="loadToRightMap"
                >
                  <span class="crimson-text">右侧地图</span>
                </DropdownItem>

                <!-- <DropdownItem v-else  disabled> 父节点不支持查看 </DropdownItem> -->
              </template>
            </Tree>
          </div>
          <div class="btnGroup">
            <Dropdown
              type="primary"
              class="but-treedata"
              @on-click="algoDropdownMenuChange"
            >
              <Button
                type="primary"
                class="btnstyle textBtnStyle system-btn-style"
                style="width: 100px"
              >
                添加
                <Icon type="ios-arrow-down"></Icon>
              </Button>
              <DropdownMenu slot="list">
                <DropdownItem name="local">本地数据</DropdownItem>
                <DropdownItem name="dataManagement">数管数据</DropdownItem>
              </DropdownMenu>
            </Dropdown>
            <!-- 移除双功能按钮 -->
            <Dropdown type="primary" class="but-treedata" @on-click="deleteMenuData">
              <Button
                type="primary"
                class="btnstyle textBtnStyle system-btn-style"
                style="width: 100px"
              >
                移除
                <Icon type="ios-arrow-down"></Icon>
              </Button>
              <DropdownMenu slot="list">
                <DropdownItem name="local">移除</DropdownItem>
                <DropdownItem name="dataManagement">删除</DropdownItem>
              </DropdownMenu>
            </Dropdown>

            <!-- <Button type="primary" class="but-treedata" @click="deleteTreeData">
              移除
            </Button> -->
          </div>
          <div class="publish">
            <Button type="primary" class="but-treedata" @click="downloadTreeData">
              下载
            </Button>
            <Button type="primary" class="but-treedata" @click="recoverTreeData">
              恢复
            </Button>
            <Button type="primary" @click="publish" style="margin-right: 7px">
              发布
            </Button>
          </div>
        </div>
        <!-- 发布 -->
        <Modal v-model="publishShow" draggable scrollable title="发布设置" :width="600">
          <h5>{{ typeText }}名称筛选条件:</h5>
          <div class="pubulishSetting">
            <div class="queryBox">
              <div style="margin-bottom: 15px">
                <span style="font-size: 16px">{{ typeText }}类型：</span>
                <Select
                  transfer
                  placeholder="请选择类型"
                  v-model="eventType"
                  @on-change="getEventName('eventType')"
                  style="width: 450px; margin-left: 10px;"
                >
                  <Option
                    v-for="item in disasterList"
                    :value="item.value"
                    :key="item.label"
                  >
                    {{ item.label }}
                  </Option>
                </Select>
              </div>
              <div style="margin-bottom: 15px">
                <span style="font-size: 16px">{{typeText}}时间：</span>
                <DatePicker
                  type="date"
                  style="width: 450px; margin-left: 10px"
                  @on-change="getEventName('eventDate')"
                  placeholder="开始时间"
                  format="yyyy-MM-dd"
                  v-model="eventDate"
                ></DatePicker>
              </div>
              <div style="margin-bottom: 15px">
                <span style="font-size: 16px">{{typeText}}标题：</span>
                <Input @on-change="getEventName('eventTitle')" v-model="eventTitle" placeholder="事件标题" style="width: 450px; margin-left: 10px"></Input>
              </div>
              <div style="margin-bottom: 15px">
                <span style="font-size: 16px">{{typeText}}地区：</span>
                <el-cascader
                  v-model="eventArea"
                  size="medium"
                  ref="cascader"
                  @change="getEventName('eventArea')"
                  clearable
                  placeholder="请选择地区"
                  :props="propsParams"
                  style="width: 450px; margin-left: 10px;">
                  <template slot-scope="{ node,data }">
                      <!--点击文本后选中整个节点-->
                    <div @click="$event.srcElement.parentNode.previousElementSibling.click()">
                      {{ data.label }}
                    </div>
                  </template>
                </el-cascader>
              </div>
            </div>
            
            <div style="margin-bottom: 15px">
              <span style="font-size: 16px">{{ typeText }}名称：</span>
              <Select
                placeholder="请选择名称.."
                transfer
                clearable
                v-model="eventId"
                @on-change="getEventId"
                style="width: 450px; margin-left: 10px"
              >
                <Option
                  v-for="item in eventNameList"
                  :value="item.value"
                  :key="item.label"
                >
                  {{ item.label }}
                </Option>
              </Select>
            </div>
            <div style="margin-bottom: 15px">
              <span style="font-size: 16px">产品类型：</span>
              <Select
                placeholder="请选择产品.."
                transfer
                clearable
                label-in-value
                v-model="productTypeValue"
                @on-change="getIamgeName"
                style="width: 450px; margin-left: 10px"
              >
                <Option
                  v-for="item in productTypeList"
                  :value="item.value"
                  :key="item.label"
                >
                  {{ item.label }}
                </Option>
              </Select>
            </div>
            <div
              style="margin-bottom: 15px"
              v-show="
                (isShowFbLine == '1' && isShowFbLineType == '1') ||
                (isShowFbLine == '2' && isShowFbLineType == '2')
              "
            >
              <span style="font-size: 16px">发布方式：</span>

              <Select
                placeholder="请选择发布方式.."
                transfer
                clearable
                label-in-value
                v-model="selectDataTypeFb"
                @on-change="selectDataTypeChange"
                style="width: 450px; margin-left: 10px"
              >
                <Option
                  v-for="item in producesType"
                  :value="item.value"
                  :key="item.label"
                >
                  {{ item.label }}
                </Option>
              </Select>
            </div>
          </div>
          <div style="margin-bottom: 10px">
            <Table
              :columns="imageNameColumns"
              :data="
                imageNameList.slice(
                  this.pageSelected * this.pageSize,
                  (this.pageSelected + 1) * this.pageSize
                )
              "
              border
              stripe
            >
            </Table>
            <Page
              :total="imageNameList.length"
              :page-size="pageSize"
              show-total
              style="margin-left: 165px"
              @on-change="changePage"
            ></Page>
          </div>
          <template #footer>
            <CButton @click="publishEvent" color="info" class="system-btn-style"
              >发布</CButton
            >
            <CButton @click="publishCanncel" color="light">取消</CButton>
          </template>
        </Modal>

        <!-- shuju -->
        <!-- 输入数据modal -->
        <Modal
          v-model="dataTreeShow1"
          draggable
          scrollable
          :transfer="true"
          style="z-index: 100000; position: absolute"
          title="选择数据"
          :width="700"
        >
          <div style="height: 450px; width: 650px; overflow: scroll">
            <Tree
              :data="selectDataTree"
              :render="renderContent"
              :check-strictly="true"
              show-checkbox
              ref="tree"
              @on-check-change="selectTreeNodeInfo"
            >
            </Tree>
          </div>
          <template #footer>
            <div
              style="display: flex; justify-content: space-between; align-items: center"
            >
              <div>
                <input
                  type="checkbox"
                  checked
                  style="margin-right: 8px"
                  v-model="isTrue"
                  @click="dataPart"
                />
                <span style="font-size: 18px; font-weight: 500">数据拆分</span>
              </div>
              <div>
                <Button @click="checkCancel" color="info" type="primary"
                  >取消勾选
                </Button>
                <Button @click="openTreeDataOk" color="info" class="system-btn-style"
                  >确定</Button
                >
                <Button @click="openTreeDataCancel" color="light">取消</Button>
              </div>
            </div>
          </template>
        </Modal>
      </div>
    </Drawer>

    <Modal
      v-model="addFileLevelModal"
      draggable
      scrollable
      title="设置文件级别"
      class="addShow"
    >
      <div style="margin: 20px">
        <div style="display: flex; margin-top: 20px">
          <span style="width: 90px">数据级别：</span>
          <Input v-model="uploadDataObj.fileLevel"></Input>
        </div>
        <div
          style="display: flex; margin-top: 20px"
          title="上传的文件将会保存在该文件夹下"
        >
          <span style="width: 106px">转存路径：</span>
          <Input v-model="uploadDataObj.uploadfolderPath"></Input>
          <CButton
            @click="selectServerFolder"
            color="info"
            class="system-btn-style"
            style="width: 45px; height: 34px; margin-left: 10px; margin-top: -2px"
            >...</CButton
          >
        </div>
      </div>
      <template #footer>
        <CButton @click="addTreeData" color="info" class="system-btn-style"
          >下一步</CButton
        >
        <CButton @click="addFileLevelModal = false" color="light">取消</CButton>
      </template>
    </Modal>

    <!-- 添加树节点 -->

    <!-- 移除树节点 -->
    <Modal v-model="delShow" draggable scrollable title="删除树节点">
      <p slot="header" class="modalHeader">
        <img src="@/assets/icons/shanchu.svg" alt />
        <span>删除树叶子节点</span>
      </p>
      <div class="modalBody">
        <p>请确实是否选择叶子节点~</p>
        <p>确认是否删除?</p>
      </div>
      <template #footer class="footerBtns">
        <CButton @click="delShow = false" color="info" class="cancel-btn">取消</CButton>
        <CButton @click="delTreeDataOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>

    <!-- 恢复移除数据 -->
    <Modal v-model="recoverShow" scrollable draggable title="数据恢复" width="675px">
      <Table
        :columns="columns"
        :data="recoverData"
        border
        stripe
        @on-select="selectedData"
        @on-select-all="selectedData"
      >
      </Table>
      <template #footer st>
        <CButton @click="recoverShow = false" color="info" class="cancel-btn"
          >取消</CButton
        >
        <CButton @click="recoverDataOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>

    <!-- 元数据查看 -->
    <Modal
      style="display: flex"
      v-model="metadataViewShow"
      title="元数据查看"
      scrollable
      draggable
      width="900"
    >
      <div style="display: flex">
        <div>
          <img :src="this.imgDetails.thumb" alt="缩略图" width="600" height="600" />
        </div>
        <div class="dataDetails">
          <span>影像详情</span>
          <table class="tableStyle">
            <tr>
              <td>卫星</td>
              <td>{{ this.dataMeta.SatelliteID }}</td>
            </tr>
            <tr>
              <td>传感器</td>
              <td>{{ this.dataMeta.SensorID }}</td>
            </tr>
            <tr>
              <td>采集时间</td>
              <td>{{ this.imgReceiveTime }}</td>
            </tr>
            <tr>
              <td>生产时间</td>
              <td>{{ this.dataMeta.ProductTime }}</td>
            </tr>
            <tr>
              <td>入库时间</td>
              <td>{{ this.dataMeta.EndTime }}</td>
            </tr>
            <tr>
              <td>云量</td>
              <td>{{ this.dataMeta.CloudPercent }}</td>
            </tr>
            <tr>
              <td>分辨率</td>
              <td>{{ this.dataMeta.ImageGSD }}</td>
            </tr>
            <tr>
              <td>轨道圈号</td>
              <td>{{ this.dataMeta.OrbitID }}</td>
            </tr>
            <tr>
              <td>景path/row</td>
              <td>{{ this.dataMeta.ScenePath }}/{{ this.dataMeta.SceneRow }}</td>
            </tr>
            <tr>
              <td>产品号</td>
              <td>{{ this.dataMeta.ProductID }}</td>
            </tr>
            <tr>
              <td>景号</td>
              <td>{{ this.dataMeta.SceneID }}</td>
            </tr>
            <tr>
              <td>左上角经/纬度</td>
              <td>
                [{{ this.dataMeta.TopLeftLongitude }},{{ this.dataMeta.TopLeftLatitude }}]
              </td>
            </tr>
            <tr>
              <td>右上角经/纬度</td>
              <td>
                [{{ this.dataMeta.TopRightLongitude }},{{
                  this.dataMeta.TopRightLatitude
                }}]
              </td>
            </tr>
            <tr>
              <td>右下角经/维度</td>
              <td>
                [{{ this.dataMeta.BottomRightLongitude }},{{
                  this.dataMeta.BottomRightLatitude
                }}]
              </td>
            </tr>
            <tr>
              <td>左下角经/纬度</td>
              <td>
                [{{ this.dataMeta.BottomLeftLongitude }},{{
                  this.dataMeta.BottomLeftLatitude
                }}]
              </td>
            </tr>
          </table>
        </div>
      </div>
    </Modal>

    <!-- 下载树节点 -->
    <!-- <Modal v-model="downShow" draggable scrollable footer-hide>
      <div id="downloadSetting">
        <label class="download-text">设置下载存储路径</label>
        <div class="download-content">
          <span>下载到：</span>
          <Input placeholder="D://12321321312" disabled></Input>
          <Button type="primary">浏览</Button>
        </div>
        <div class="btnGroup">
          <Button type="primary" @click="downloadTreeDataOk">下载</Button>
          <Button type="primary" @click="downShow = false">取消</Button>
        </div>
      </div>
    </Modal> -->
    <!-- shp颜色设置 -->
    <Modal v-model="shpColorShow" scrollable draggable title="颜色设置" width="450px">
      颜色选择：<ColorPicker
        v-model="shpColor"
        style="width: 280px; margin-left: 20px"
        recommend
      />
      <template #footer st>
        <CButton @click="shpColorShow = false" color="info" class="system-btn-style"
          >取消</CButton
        >
        <CButton @click="shpColorOk" color="info" class="system-btn-style">确定</CButton>
      </template>
    </Modal>
    <!-- 样式设置 -->
    <Modal
      v-model="styleShow"
      draggable
      scrollable
      footer-hide
      title="样式设置"
      width="450px"
    >
      <div class="styletree-style" style="border: solid 0.2px #f5f5f5">
        <div class="style-content">
          <span>透明度</span>
          <Slider class="style-slider" v-model="percent"></Slider>
        </div>

        <div class="style-content" style="margin-top: 10px">
          <span>拉伸方式</span>
          <Select style="width: 330px; margin-left: 20px" v-model="stretchStyle">
            <Option value="percentMinimumMaximum">百分比拉伸</Option>
            <Option value="histogramEqualize">直方图均衡化拉伸</Option>
            <Option value="minimumMaximum">最大最小值拉伸</Option>
            <Option value="standardDeviation">标准差拉伸</Option>
            <!-- <Option value="grammaStretch">伽马拉伸</Option> -->
          </Select>
        </div>

        <div class="style-choice">
          <div
            id="styleapply"
            style="width: 100px; font-size: 5px; border: solid 0.2px #f5f5f5"
          >
            <Button
              type="primary"
              style="width: 70px; margin-top: 60px"
              @click="settingRgb"
              >RGB合成</Button
            >
            <Button
              type="primary"
              style="width: 70px; margin-top: 40px"
              @click="settingStrecth"
              >拉伸</Button
            >
          </div>
          <div v-show="rgbSettingShow" style="width: 350px; border: solid 0.1px #f5f5f5">
            <Table :columns="columnNames" :data="bandsData">
              <template slot-scope="{ row, index }" slot="band">
                <i-select transfer v-model="styleBands[index]">
                  <i-option
                    v-for="item in bandOptions"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}
                  </i-option>
                </i-select>
              </template>
            </Table>
          </div>
          <div v-show="strSettingShow" style="width: 350px; border: solid 0.1px #f5f5f5">
            <div style="margin-left: 20px; line-height: 28px">
              <span>波段：</span>

              <Select style="width: 252px" v-model="bandNumber">
                <Option v-for="item in bandOptions" :value="item.value" :key="item.value"
                  >{{ item.label }}
                </Option>
              </Select>
            </div>
            <div style="margin-left: 20px" class="colorbar_box">
              <span>颜色：</span>
              <input
                type="text"
                readonly="readonly"
                class="colorbar_ipt"
                v-model="bandColor"
                :style="{ background: inputStyle }"
                @click="openShow()"
              />
              <i :class="{ active: active }" class="el-icon-arrow-down"></i>

              <ul v-show="show">
                <li
                  v-for="item in options"
                  :key="item.value"
                  :style="{ background: item.bgStyle }"
                  @click="changeColor(item)"
                ></li>
              </ul>
            </div>
            <!-- <div style="margin-top: 20px ;margin-left: 20px">
              <span>颜色：</span>
              <ColorPicker
                v-model="bandColor"
                :colors="colorList"
                style="width: 200px; margin-left: 20px"
              />
            </div> -->
          </div>
          <div
            v-show="colorSettingShow"
            style="width: 350px; border: solid 0.2px#A8A8A8"
          ></div>
        </div>
      </div>
      <div class="stylebutton">
        <Button type="primary" style="width: 60px; margin-left: 80px" @click="deleteStyle"
          >取消</Button
        >
        <Button
          type="primary"
          style="width: 60px; margin-left: 60px"
          @click="applicationTile"
          >应用</Button
        >
        <Button
          type="primary"
          style="width: 80px; margin-left: 60px"
          @click="colorApplication"
          >颜色应用</Button
        >
      </div>
    </Modal>
    <!-- shp选择目录 -->
    <CModal
      title="推送任务选择目录"
      color="info"
      :show.sync="showPushTaskZtreeModal"
      :closeOnBackdrop="false"
      size="lg"
      centered
    >
      <div class="treeDiv">
        <ul id="pushTaskTree" class="ztree"></ul>
      </div>

      <template #header>
        <h5>选择目录</h5>
        <CButtonClose @click="pushTaskMenuCancel" />
      </template>
      <template #footer>
        <CButton @click="pushTaskMenuOk" color="info" class="system-btn-style"
          >确定</CButton
        >
        <CButton @click="pushTaskMenuCancel" color="light">取消</CButton>
      </template>
    </CModal>
    <!-- 卫星传感器选择 -->
    <CModal
      title="选择信息"
      color="info"
      :show.sync="showSelectAddInfoZtreeModal"
      :closeOnBackdrop="false"
      centered
    >
      <div class="treeDiv1">
        <ul id="selectInfoTree" class="ztree"></ul>
      </div>

      <template #header>
        <h5>选择</h5>
        <CButtonClose @click="selectAddInfoCancel" />
      </template>
      <template #footer>
        <CButton @click="selectAddInfoCancel" color="light">取消</CButton>
        <CButton @click="selectAddInfoOk" color="info">确定</CButton>
      </template>
    </CModal>

    <FileCatalog
      ref="refFileCatalogModal"
      v-if="fileCatalogModal"
      :modalShow="fileCatalogModal"
      @closed="fileCatalogModalClose"
      @menuOk="fileCatalogModalOk"
      @handleWorkflow="fileCatalogModalWorkflow"
    ></FileCatalog>

    <Modal
      v-model="dataManagementModal"
      draggable
      scrollable
      title="数管数据查询"
      width="1400px"
      class="dataManagementModal"
      @on-ok="dataManageModalOk"
      @on-cancel="dataManagementModalCancel"
    >
      <DataManagementQuery ref="dataManagementMap" />
      <template #footer>
        <CButton @click="dataManagementModalCancel" color="light">取消</CButton>
        <CButton @click="dataManageModalOk" color="info" class="system-btn-style"
          >添加数据</CButton
        >
        <CButton @click="submitTask" color="info" class="system-btn-style"
          >提交任务</CButton
        >
      </template>
    </Modal>
    <Modal
      v-model="deleteManagementModal"
      draggable
      scrollable
      title="删除数据"
      width="600px"
      height="700px"
      class="deleteManagementModal"
    >
      <p slot="header" class="modalHeader">
        <img src="@/assets/icons/shanchu.svg" alt />
        <span>删除树节点</span>
      </p>
      <div class="modalBody">
        <p>是否从储存上删除数据</p>
        <p>请确认是否删除?</p>
      </div>

      <template #footer>
        <CButton @click="deleteManagementModal = false" color="light">取消</CButton>
        <CButton @click="deleteManageModalOk" color="info" class="system-btn-style"
          >确定</CButton
        >
      </template>
    </Modal>
  </div>
</template>
<script>
import axios from "axios";
import iView, { Spin } from "iview";

import FileCatalog from "../jobProcess/fileCatalog.vue";

import DataManagementQuery from "./dataManagementQuery.vue";
import wktToGeoJson from "../../../src/utils/WKTToGeoJson.js";

// import Legend from "../../views/Legend";
// import qs from "qs";
// import X2JS from "x2js";
export default {
  name: "leftDrawer",
  props: {
    modelShow: {
      type: Boolean,
      default: false,
    },
    modelShow1: {
      type: Boolean,
      default: false,
    },
    map: {
      type: Object,
    },
    afterMap: {
      type: Object,
    },

    // currentDrawGeometry1: {
    //   type: Array,
    //   default: [],
    // },
  },
  components: {
    FileCatalog,
    DataManagementQuery,
  },
  data() {
    return {
      //样式修改参数
      styleLaterPercent: -1,
      styleLaterBands: [],
      styleLaterStretch: "",
      selectDataType: false,
      timeout: null,
      showTooltip: true,

      selcetFilePath: [],
      selcetFilePath1: [],
      timer: "",
      dataManagementModal: false,
      addFileLevelModal: false,
      fileCatalogModal: false,
      current: 0,

      uploadDataObj: {
        fileLevel: "L1A",
        uploadfolderPath: "/pie/data/wx01wxyg102/01/Disaster",
      },

      customerArea: {},
      regionSelected: "", //按区域选择
      satelliteSelected: "", //按卫星选择
      regionList: [], //可选择的区域

      customerRegionList: [],
      currentDrawGeometryList: [], //地图绘制要素集合

      fromRadio: "1",

      data1: [
        {
          name: "hello",
          age: 1,
        },
        {
          name: "world",
          age: 2,
        },
      ],
      columns: [
        {
          type: "selection",
          width: 60,
          align: "center",
        },
        {
          title: "序号",
          type: "index",
          width: 80,
          align: "center",
        },
        {
          title: "所属区域",
          key: "region",
          width: 200,
        },
        {
          title: "数据名称",
          key: "name",
          width: 300,
        },
      ],
      imageNameColumns: [
        {
          title: "序号",
          type: "index",
          width: 80,
          align: "center",
        },
        {
          title: "数据名称",
          key: "imageName",
          align: "center",
        },
      ],
      drawerShow: false,
      dataSettingShow: true, //设置
      dataTreeShow: false, //数据目录
      dataTreeShow1: false,
      taskName: "", //事件名称
      taskTime: "", //事件
      TaskAddress: "", //地点
      TaskDisasterType: "", //灾种
      taskID: "", //任务id
      disasterTaskStatus: 0, //状态
      satellites: "", //卫星
      sensors: "", //传感器
      productLevel: "LEVEL1A", //产品级别
      taskAreaList: [], //区域结果
      drawingAreaList: [], //自定义绘制结果

      // regionBlock: true,

      shpPath: "",
      showPushTaskZtreeModal: false, //矢量文件show
      showSelectAddInfoZtreeModal: false, //卫星传感器show

      regionCascader: [], //级联选择区域
      regionResultList: [], //区域结果
      regionResultIDList: [],
      satelliteResultNameList: [],
      selectInfoList: [], //选择的信息
      productLevelList: ["LEVEL1A", "LEVEL2"],
      producesType: [],
      currentSelectData: [], //当前勾选的数据
      selectDataTypeFb: "",
      isShowFbLine: "3", //是否显示发布方式
      isShowFbLineType: "3",

      // 区域的变量
      currentRegionName: "",
      currentRegionList: [],
      currentregionType: 2,
      currentRegionCode: "",
      currentRegionInfo: {},
      currentSelectRegions: [],
      currentTreeNode: null, //右键选中数据
      imgDetails: {},
      treeNodeSelected: [], //树节点
      recoverData: [], //全部恢复数据
      allSelectData: [], //树结构中的所有数据
      recoverNodeList: [], //要恢复的
      addShow: false, //添加
      delShow: false, //移除
      nodes: [], //勾选叶子节点数据
      dataNote0: [],
      dataNote1: [],
      recoverShow: false, //数据恢复
      metadataViewShow: false, //元数据查看
      dataMeta: {}, //元数据xml元素
      imgReceiveTime: "", //元数据采集时间
      downShow: false, //下载
      styleShow: false, //样式
      //transparency: null, //透明度
      stretchStyle: "standardDeviation",
      rgbSettingShow: true, //Rgb设置
      strSettingShow: false, //拉伸设置
      colorSettingShow: false, //色彩映射设置

      //样式参数
      selectTileData: [],
      demColor: [],
      options: [
        {
          value: "1",
          label: "黑白",
          bgStyle: "linear-gradient(to right, #000000, #ffffff)",
        },
        {
          value: "2",
          label: "白黑",
          bgStyle: "linear-gradient(to right, #ffffff, #000000)",
        },
        {
          value: "3",
          label: "蓝色 浅蓝",
          bgStyle: "linear-gradient(to right, #0000ff, #00ffff)",
        },
        {
          value: "4",
          label: "浅蓝 紫色",
          bgStyle: "linear-gradient(to right, #00ffff, #ff00ff)",
        },
        {
          value: "5",
          label: "蓝色 浅蓝 紫色 白色",
          bgStyle: "linear-gradient(to right, #0000ff, #00ffff, #ff00ff, #ffffff)",
        },
        {
          value: "6",
          label: "白色 绿色",
          bgStyle: "linear-gradient(to right, #ffffff, #00ff00)",
        },
        {
          value: "7",
          label: "绿色 红色",
          bgStyle: "linear-gradient(to right, #00ff00, #ff0000)",
        },
        {
          value: "8",
          label: "红色 黄色",
          bgStyle: "linear-gradient(to right, #ff0000, #ffff00)",
        },
        {
          value: "9",
          label: "白色 绿色 红色 黄色",
          bgStyle: "linear-gradient(to right, #ffffff, #00ff00, #ff0000, #ffff00)",
        },
        {
          value: "10",
          label: "蓝色 紫色",
          bgStyle: "linear-gradient(to right, #0000ff, #ff00ff)",
        },
        {
          value: "11",
          label: "紫色 绿色",
          bgStyle: "linear-gradient(to right, #ff00ff, #00ff00)",
        },
        {
          value: "12",
          label: "绿色 黄色",
          bgStyle: "linear-gradient(to right, #00ff00, #ffff00)",
        },
        {
          value: "13",
          label: "蓝色 紫色 绿色 黄色",
          bgStyle: "linear-gradient(to right, #0000ff, #ff00ff, #00ff00, #ffff00)",
        },
        {
          value: "14",
          label: "黄色 浅蓝",
          bgStyle: "linear-gradient(to right, #ffff00, #00ffff)",
        },
        {
          value: "15",
          label: "浅蓝 白色",
          bgStyle: "linear-gradient(to right, #00ffff, #ffffff)",
        },
        {
          value: "16",
          label: "白色 红色",
          bgStyle: "linear-gradient(to right, #ffffff, #ff0000)",
        },
        {
          value: "17",
          label: "黄色 浅蓝 白色 红色",
          bgStyle: "linear-gradient(to right, #ffff00, #00ffff, #ffffff, #ff0000)",
        },
        {
          value: "18",
          label: "蓝色 绿色",
          bgStyle: "linear-gradient(to right, #0000ff, #00ff00)",
        },
        {
          value: "19",
          label: "绿色 浅蓝",
          bgStyle: "linear-gradient(to right, #00ff00, #00ffff)",
        },
        {
          value: "20",
          label: "浅蓝 红色",
          bgStyle: "linear-gradient(to right, #00ffff, #ff0000)",
        },
        {
          value: "21",
          label: "蓝色 绿色 浅蓝 红色",
          bgStyle: "linear-gradient(to right, #0000ff, #00ff00, #00ffff, #ff0000)",
        },
        {
          value: "22",
          label: "红色 紫色",
          bgStyle: "linear-gradient(to right, #ff0000, #ff00ff)",
        },
        {
          value: "23",
          label: "紫色 黄色",
          bgStyle: "linear-gradient(to right, #ff00ff, #ffff00)",
        },
        {
          value: "24",
          label: "黄色 白色",
          bgStyle: "linear-gradient(to right, #ffff00, #ffffff)",
        },
        {
          value: "25",
          label: "红色 紫色 黄色 白色",
          bgStyle: "linear-gradient(to right, #ff0000, #ff00ff, #ffff00, #ffffff)",
        },
        {
          value: "26",
          label: "蓝色 浅蓝 黄色 红色",
          bgStyle: "linear-gradient(to right, #0000ff, #00ff00, #ffff00, #ff0000)",
        },
        {
          value: "27",
          label: "27",
          bgStyle:
            "linear-gradient(to right, #9e0142, #d53e4f, #f46d43, #fdae61, #fee08b, #ffffbf, #e6f598, #abdda4,#66c2a5, #3288bd, #5e4fa2)",
        },
        {
          value: "28",
          label: "28",
          bgStyle:
            "linear-gradient(to right, #a50026, #d73027, #f46d43, #fdae61, #fee08b, #ffffbf, #d9ef8b, #a6d96a, #66bd63, #1a9850, #006837)",
        },
        {
          value: "29",
          label: "29",
          bgStyle:
            "linear-gradient(to right, #a50026, #d73027, #f46d43, #fdae61, #fee090, #ffffbf, #e0f3f8, #abd9e9, #74add1, #4575b4, #313695)",
        },
        {
          value: "30",
          label: "30",
          bgStyle:
            "linear-gradient(to right, #67001f, #b2182b, #d6604d, #f4a582, #fddbc7, #ffffff, #e0e0e0, #bababa, #878787, #4d4d4d, #1a1a1a)",
        },
        {
          value: "31",
          label: "31",
          bgStyle:
            "linear-gradient(to right, #67001f, #b2182b, #d6604d, #f4a582, #fddbc7, #f7f7f7, #d1e5f0, #92c5de, #4393c3, #2166ac, #053061)",
        },
        {
          value: "32",
          label: "32",
          bgStyle:
            "linear-gradient(to right, #7f3b08, #b35806, #e08214, #fdb863, #fee0b6, #f7f7f7, #d8daeb, #b2abd2, #8073ac, #542788, #2d004b)",
        },
        {
          value: "33",
          label: "33",
          bgStyle:
            "linear-gradient(to right, #40004b, #762a83, #9970ab, #c2a5cf, #e7d4e8, #f7f7f7, #d9f0d3, #a6dba0, #5aae61, #1b7837, #00441b)",
        },
        {
          value: "34",
          label: "34",
          bgStyle:
            "linear-gradient(to right, #8e0152, #c51b7d, #de77ae, #f1b6da, #fde0ef, #f7f7f7, #e6f5d0, #b8e186, #7fbc41, #4d9221, #276419)",
        },
        {
          value: "35",
          label: "35",
          bgStyle:
            "linear-gradient(to right, #543005, #8c510a, #bf812d, #dfc27d, #f6e8c3, #f5f5f5, #c7eae5, #80cdc1, #35978f, #01665e, #003c30)",
        },
      ],
      //shp颜色设置
      shpColorShow: false,
      shpColor: "#088",
      shpData: {},
      //颜色选择
      inputStyle: "linear-gradient(to right, #000000, #ffffff)",
      percent: 20,
      bandOptions: [],
      styleBands: [],
      bandNumber: "", //波段个数
      bandColor: "",
      bandCount: -1,
      columnNames: [
        {
          title: "颜色通道",
          key: "channel",
          align: "center",
        },
        {
          title: "波段",
          key: "band",
          align: "center",
          slot: "band",
        },
      ],
      //颜色通道
      bandsData: [
        {
          channel: "红色",
          band: "",
        },
        {
          channel: "绿色",
          band: "",
        },
        {
          channel: "蓝色",
          band: "",
        },
      ],

      editIndex: -1,
      active: false,
      show: false,
      hhh: "",

      url: "",
      filePath: "",
      fileName: "",

      showPop: false,
      regionProviceCode: 22,
      disasterId: 1,

      dataList: [], //初始数据
      dataTreeList: [], //最终数据
      selectDataTree: [],
      // nodataList: "", //提示没有数据

      //切片发布参数
      lastSelected: [],
      lastX1: [],
      lastX2: [],
      lastShp: [],
      globalLineData: [], //所有的图框坐标
      layerID: "",
      //移除
      deleteManagementModal: false,
      imgType: "", //右侧产品输入数据类型
      isTrue: false, //是否拆分数据
      //发布模块数据
      publishShow: false,
      getPublishId: [],
      eventType: "FOREST_STEPPE_FIRE",
      typeText: '事件',
      eventDate: "",
      eventTitle: "",
      eventArea: "",
      propsParams: {
        lazy: true, //可以理解为开关，什么时候结束
        lazyLoad: this.lazyLoad,
        checkStrictly: true,
        multiple:false
      },
      eventName: "",
      productType: "",
      productTypeValue: "",
      eventTypeResult: [],
      imageNameList: [],
      eventId: "",
      disasterList: [
        { label: "地震", value: "EARTHQUAKE" },
        { label: "地质灾害", value: "LANDSLIDE" },
        { label: "洪涝", value: "FLOOD" },
        { label: "火灾", value: "FIRE" },
        { label: "安全生产", value: "SAFE_PRODUCTION" },
        { label: "台风", value: "TYPHOON" },
        // { label: "干旱", value: "DROUGHT" },
        // { label: "冰凌", value: "ICE_CREAM" },
        { label: "森林草原火灾", value: "FOREST_STEPPE_FIRE"},
        { label: "其他", value: "OTHER" },
        
      ],
      eventNameList: [],
      productTypeList: [
        { label: "灾前影像", value: "BEFORE" },
        { label: "灾后影像", value: "AFTER" },
        // { label: "卫星应用产品图鉴", value: "TOPIC" },
        // { label: "解译输入影像", value: "ESTIMATE_INPUT" },
        // { label: "解译输出影像", value: "ESTIMATE_OUTPUT" },
        { label: "卫星应用产品", value: "DISASTER_TOPIC" },
        { label: "基础数据", value: "DISASTER_BASE" },
      ],
      pageSize: 3,
      pageSelected: 0,
    };
  },
  mounted() {
    this.taskID = this.$route.query.id;
    this.disasterTaskStatus = this.$route.query.status;
    this.getDisasterInfoById();
    this.getSatelleData();
    this.getTreeDataList(); //获取数据目录树
    this.getCustomerRegionList(); //自定义绘制区域列表
    this.foldLeft(); //左侧自由拖拽
  },
  watch: {
    modelShow: {
      handler(val) {
        this.drawerShow = val;
      },
      deep: true,
      immediate: true,
    },
    modelShow1: {
      handler(val) {
        this.dataTreeShow1 = val;
      },
      deep: true,
      immediate: true,
    },
    eventType: {
      handler(val) {
        if (['DROUGHT','ICE_CREAM'].indexOf(val) > -1) {
          this.typeText = '风险'
        } else {
          this.typeText = '事件'
        }
        // this.productTypeValue = "";
        // this.publish();
      }
    }
  },
  methods: {
    lazyLoad(node, resolve) {
      let self = this;
      if (!node) {
        return false;
      }
      const { level } = node;
      if (level === 0) {
        let path = this.$api.queryDealApi.regionQueryProvince;
        let param = {};
        self.http.get(path, param).then((res) => {
          resolve(
            res.data.data.map((val) => {
              return {
                  value: val.code,
                  label: val.name,
                  leaf: val.code == 72,
                };
            })
          )
        })
      } else if (level === 1) {
        let path = this.$api.queryDealApi.regionQueryCityByProvince + node.value;
        self.http.get(path).then((res) => {
          resolve(
            res.data.data.map((val) => {
              return {
                  value: val.code,
                  label: val.name,
                  leaf: val.code == 8101 || val.code == 8201,
                };
            })
          )
        })
      } else if (level === 2) {
        let path = this.$api.queryDealApi.regionQueryAreaByCityCode + node.value;
        self.http.get(path).then((res) => {
          resolve(
            res.data.data.map((val) => {
              return {
                  value: val.code,
                  label: val.name,
                  leaf: true,
                };
            })
          )
        })
      }
    },
    //修改发布方式
    selectDataTypeChange(value) {
      this.selectDataTypeFb = value.value;
    },
    //加载到右侧地图
    loadToRightMap() {
      let _this = this;
      _this.loadShpAndImg(_this.currentTreeNode, "afterMap");
    },
    foldLeft() {
      this.asideWidth = this.asideWidth === 0 ? 300 : 0;
    },

    openTreeData(val) {
      this.imgType = val;
      let arr = this.dataList;
      console.log(arr, "arr");
      let Arr = [];
      let expand = true;
      let j = -1;
      let check = "";
      // 处理过程
      let imgpath = "";
      for (let i = 0; i < arr.length; i++) {
        // 先判断  Arr是否为空
        arr[i].produceTime = arr[i].produceTime ? arr[i].produceTime.slice(0, 10) : "";
        if (Arr.length == 0) {
          imgpath = arr[i].path + "/" + arr[i].name;
          if (!arr[i].level.includes("L1")) {
            if (this.selcetFilePath.includes(imgpath)) {
              console.log("true");
              check = true;
            } else {
              check = false;
            }
            let param = {
              title: arr[i].produceTime,
              expand: true,
              contextmenu: true,
              children: [
                {
                  title: arr[i].level,
                  produceTime: arr[i].produceTime,
                  expand: expand,
                  contextmenu: true,
                  children: [
                    {
                      title: arr[i].name,
                      produceTime: arr[i].produceTime,
                      level: arr[i].level,
                      checked: check,
                      id: arr[i].id,
                      meta: arr[i].meta,
                      path: arr[i].path,
                      dataId: arr[i].dataId,
                      region: arr[i].region,
                      status: arr[i].status,
                      tsakId: arr[i].taskId,
                      thumb: arr[i].thumb,
                      contextmenu: true,
                      expand: expand,
                    },
                  ],
                },
              ],
            };
            // 判断节点的状态
            if (param.children[0].children[0].status == "normal") {
              Arr.push(param);
              j++;
            }
          }
        } else {
          //Arr 不为空
          imgpath = arr[i].path + "/" + arr[i].name;
          if (arr[i].produceTime == Arr[j].title && !arr[i].level.includes("L1")) {
            //createTime相同
            let k = Arr[j].children.length - 1;
            if (arr[i].level != Arr[j].children[k].title) {
              if (this.selcetFilePath.includes(imgpath)) {
                console.log("true");
                check = true;
              } else {
                check = false;
              }

              //level不相同
              let param = {
                title: arr[i].level,
                produceTime: arr[i].produceTime,
                expand: true,
                contextmenu: true,
                children: [
                  {
                    title: arr[i].name,
                    checked: check,
                    produceTime: arr[i].produceTime,
                    level: arr[i].level,
                    id: arr[i].id,
                    meta: arr[i].meta,
                    path: arr[i].path,
                    dataId: arr[i].dataId,
                    region: arr[i].region,
                    status: arr[i].status,
                    tsakId: arr[i].taskId,
                    thumb: arr[i].thumb,
                    expand: expand,
                    contextmenu: true,
                  },
                ],
              };
              // 判断节点的状态
              if (param.children[0].status == "normal") {
                Arr[j].children.push(param);
              }
            } else {
              //level相同
              if (this.selcetFilePath.includes(imgpath)) {
                console.log("true");
                check = true;
              } else {
                check = false;
              }

              let param = {
                title: arr[i].name,
                checked: check,
                produceTime: arr[i].produceTime,
                level: arr[i].level,
                expand: expand,
                id: arr[i].id,
                meta: arr[i].meta,
                path: arr[i].path,
                dataId: arr[i].dataId,
                region: arr[i].region,
                status: arr[i].status,
                tsakId: arr[i].taskId,
                thumb: arr[i].thumb,
                contextmenu: true,
              };
              // 判断节点的状态
              if (param.status == "normal") {
                Arr[j].children[k].children.push(param);
              }
            }
          } else {
            imgpath = arr[i].path + "/" + arr[i].name;
            if (!arr[i].level.includes("L1")) {
              //createTime不相同
              if (this.selcetFilePath.includes(imgpath)) {
                check = true;
              } else {
                check = false;
              }
              let param = {
                title: arr[i].produceTime,
                expand: true,
                contextmenu: true,
                children: [
                  {
                    title: arr[i].level,
                    produceTime: arr[i].produceTime,
                    expand: expand,
                    contextmenu: true,
                    children: [
                      {
                        title: arr[i].name,
                        produceTime: arr[i].produceTime,
                        level: arr[i].level,
                        checked: check,
                        id: arr[i].id,
                        meta: arr[i].meta,
                        path: arr[i].path,
                        dataId: arr[i].dataId,
                        region: arr[i].region,
                        status: arr[i].status,
                        tsakId: arr[i].taskId,
                        thumb: arr[i].thumb,
                        contextmenu: true,
                        expand: expand,
                      },
                    ],
                  },
                ],
              };
              if (param.children[0].children[0].status == "normal") {
                Arr.push(param);
                j++;
              }
            }
            // 判断节点的状态
          }
        }
      }
      this.selectDataTree = Arr;
      console.log(this.selcetFilePath, "selcetFilePath");
      this.dataTreeShow1 = true;
    },
    selectTreeNodeInfo(data) {
      let nodes = [];
      this.selcetFilePath1 = [];
      data.forEach((node) => {
        if (!node.children) {
          //添加输入数据路径
          let filePath = node.path + "/" + node.title;
          this.selcetFilePath1.push(filePath);
          nodes.push(node);
        }
      });
    },
    // 拆分数据
    dataPart() {
      this.isTrue = !this.isTrue;
      console.log(this.isTrue);
      this.$emit("dataPart", this.isTrue);
    },
    checkCancel() {
      let arr = [];
      this.selectDataTree.forEach((item) => {
        item.children[0].children.forEach((ele) => {
          ele.checked = false;
        });
        arr.push(item);
      });
      this.selectDataTree = arr;
      console.log(this.selectDataTree);
    },
    openTreeDataOk() {
      // this.$emit("updateDir", this.selcetFilePath1);
      let selcet =
        this.selcetFilePath1.length !== 0 ? this.selcetFilePath1 : this.selcetFilePath;
      console.log(selcet);
      if (this.imgType == "imgDir") {
        this.$emit("updateDir", selcet);
      } else if (this.imgType == "imgZQST") {
        this.$emit("updataZQST", selcet);
      } else if (this.imgType == "imgZZST") {
        this.$emit("updataZZST", selcet);
      } else if (this.imgType == "imgFont") {
        this.$emit("updataFont", selcet);
      } else if (this.imgType == "imgBack") {
        this.$emit("updataBack", selcet);
      } else if (this.imgType == "FrontNDVI") {
        this.$emit("updataFrontNDVI", selcet);
      } else if (this.imgType == "AfterNDVI") {
        this.$emit("updataAfterNDVI", selcet);
      }
      this.selcetFilePath1 = [];
      this.isTrue = false;
      this.dataTreeShow1 = false;
    },
    openTreeDataCancel() {
      this.selcetFilePath1 = [];
      this.isTrue = false;
      this.dataTreeShow1 = false;
    },
    renderContent(h, { data }) {
      let texts = "";
      if (data.title !== null && data.title !== undefined && data.title !== "") {
        texts = data.title;
      }
      return h(
        "div",
        {
          style: {
            display: "inline",
            width: "100%",
            cursor: "pointer",
          },
          on: {
            // 监听鼠标滚轮 防抖函数解决滚轮滚动出现tooltip闪烁
            // mousewheel: () => {
            //   // 不滚动时清除定时器 不显示tooltip
            //   clearTimeout(this.timeout);
            //   this.showTooltip = false;
            //   this.timeout = setTimeout(() => {
            //     this.showTooltip = true;
            //     //clearTimeout(this.timeout);
            //   }, 500);
            // },
            // 设置事件为被动 不会因为主线程影响到这个事件
            passive: true,
          },
        },
        this.showTooltip
          ? [
              h(
                "Tooltip",
                {
                  props: {
                    placement: "top",
                    transfer: true,
                    maxWidth: 270,
                  },
                },
                [
                  texts,
                  h(
                    "span",
                    {
                      slot: "content",
                      style: {
                        whiteSpace: "normal",
                      },
                    },
                    data.title
                  ),
                ]
              ),
            ]
          : [
              h(
                "span",
                {
                  slot: "content",
                  style: {
                    whiteSpace: "normal",
                  },
                },
                data.title
              ),
            ]
      );
    },

    selectServerFolder() {
      let _this = this;
      this.serverFolder = true;
      this.fileCatalogModal = true; // 打开弹框
      this.$nextTick(() => {
        _this.$refs.refFileCatalogModal.initFileTree(
          {
            type: { name: "dir" },
          },
          false
        );
        _this.$refs.refFileCatalogModal.handleShow(true);
      });
    },

    drawGeometryColor(geojson, layerId, shpColor) {
      console.log(shpColor, "shpColor");
      let shpType = geojson.features[0].geometry.type;
      let self = this;
      self.map.addSource(layerId, {
        type: "geojson",
        data: geojson,
      });
      if (shpType == "Point") {
        self.map.addLayer({
          id: layerId,
          type: "circle",
          source: layerId,
          layout: {},
          paint: {
            "circle-opacity": 0.5,
            "circle-radius": 6,
            "circle-color": shpColor,
          },
        });
      } else if (shpType == "MultiLineString") {
        self.map.addLayer({
          id: layerId,
          type: "line",
          source: layerId,
          layout: {
            "line-cap": "round",
          },
          paint: {
            "line-opacity": 0.5,
            "line-color": shpColor,
            "line-width": 8,
          },
        });
      } else {
        self.map.addLayer({
          id: layerId,
          type: "fill",
          source: layerId,
          layout: {},
          paint: {
            "fill-color": shpColor,
            "fill-opacity": 0.5,
          },
        });
      }
      // self.map.addLayer({
      //   id: layerId,
      //   type: "fill",
      //   source: layerId,
      //   layout: {},
      //   paint: {
      //     "fill-color": shpColor,
      //     "fill-opacity": 0.5,
      //   },
      // });
      // this.showToCenter(geojson.features[0].geometry.coordinates);
    },
    //矢量数据加载
    getRegionByShp(shpPath, isShow) {
      let layerId = shpPath.id + "";
      if (!isShow) {
        this.removeLayer(layerId);
        return;
      }
      let path = this.$api.taskManageApi.disasterShpFileQuery;
      let param = {
        fileName: shpPath.path + "/" + shpPath.title,
      };

      this.http.post(path, param).then((res) => {
        if (res.data.code == 200) {
          let shpDataRegion = res.data.data;

          this.drawGeometry(shpDataRegion, layerId);
        } else {
          this.$Message.info("读取shp文件出错");
        }
        // 绘制区域
        //this.$emit("drawGeometry", shpDataRegion.features[0]);
      });
    },
    getRegionByShpColor(shpPath) {
      let layerId = shpPath.id + "";
      if (this.map.getLayer(layerId)) {
        this.removeLayer(layerId);
      }
      let path = this.$api.taskManageApi.disasterShpFileQuery;
      let param = {
        fileName: shpPath.path + "/" + shpPath.name,
      };

      this.http.post(path, param).then((res) => {
        if (res.data.code == 200) {
          let shpDataRegion = res.data.data;
          let shpColor = this.shpColor;
          this.drawGeometryColor(shpDataRegion, layerId, shpColor);
        }
        this.shpColor = "";
      });
    },

    dataManageModalOk() {
      let data = this.$refs.dataManagementMap.getQueryData();
      this.dataManagementModal = false;
      let path = this.$api.emergencyMonitorApi.addAssociateDataBySG + this.taskID;

      let param = {
        images: data.data,
        level: data.level.substring(4, 6),
        path: "/pie/data/wx01wxyg102/01/Disaster",
      };

      this.loading('正在上传数据，请稍后哦~"');
      this.http.post(path, param).then((res) => {
        Spin.hide();
        if (res.data.success) {
          this.$Message.info("保存数据成功，立即刷新目录树");
          this.getTreeDataList();
        } else {
          this.$Message.error(res.data.message);
        }
      });
      this.$refs.dataManagementMap.reset();
    },
    dataManagementModalCancel() {
      this.$refs.dataManagementMap.reset();
      this.dataManagementModal = false;
    },
    //提交任务
    submitTask() {
      this.$refs.dataManagementMap.handleTask();
      this.dataManagementModal = false;
    },
    deleteManageModalOk() {
      let arr = this.nodes;
      for (let i = 0; i < arr.length; i++) {
        let id = arr[i].id;
        let temp = {
          id: id,
        };
        //console.log(arr,"arr")
        let path = this.$api.emergencyMonitorApi.deleteData + id;
        this.http.delete(path, temp).then((res) => {
          if (res.data.success) {
            this.getTreeDataList();
          } else {
            this.$Message.error(res.data.message);
          }
        });
      }
      this.$Message.info("删除数据成功，请刷新目录树~");
      this.deleteManagementModal = false;
    },
    algoDropdownMenuChange(val) {
      let _this = this;
      if (val === "local") {
        this.addFileLevelModal = true;
      } else if (val === "dataManagement") {
        this.dataManagementModal = true;
        // this.gettestMap();
        clearTimeout(this.timer);
        this.timer = setTimeout(() => {
          this.$refs.dataManagementMap.resizeMap();
          // let areas = _this.getSearchRegion();
          // this.$refs.dataManagementMap.setcurrentRegionInfo(areas);
        }, 200);
      }
    },
    deleteMenuData(val) {
      let _this = this;
      if (val === "local") {
        this.delShow = true;
      } else if (val === "dataManagement") {
        this.deleteManagementModal = true;
      }
    },
    fileCatalogModalWorkflow(path) {
      this.fileCatalogModal = false;
      let temp = path.split("#TASK#");
      console.log(temp);
      if (temp.length > 3)
        this.$Message.info("当前选择大于3个文件,系统会自动处理前三个文件");
      let imagePath = path.split("#TASK#").slice(0, 3);
      let path1 = this.$api.emergencyMonitorApi.localWorkflow + this.taskID;
      let param = {
        images: imagePath,
        path: this.uploadDataObj.uploadfolderPath,
      };
      console.log(param);
      this.http.post(path1, param).then((res) => {
        if (res.data.success) {
          this.$Message.info("正在执行，请稍后~");
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
    fileCatalogModalOk(path) {
      this.fileCatalogModal = false;
      if (this.serverFolder) {
        this.uploadDataObj.uploadfolderPath = path;
        this.serverFolder = false;
        return;
      }
      let temp = path.split("#TASK#");
      if (temp.length > 3)
        this.$Message.info("当前选择大于3个文件,系统会自动处理前三个文件");
      this.selectFilePath = path.split("#TASK#").slice(0, 3);

      this.submitLocalFile();
    },
    fileCatalogModalClose() {
      this.fileCatalogModal = false;
      this.serverFolder = false;
    },
    //加载图层
    loading(text) {
      if (!text) text = "加载中，请稍后...";
      Spin.show({
        render: (h) => {
          return h("div", [
            h("Icon", {
              class: "spin-icon-load",
              props: {
                type: "ios-loading",
                size: 30,
              },
            }),
            h("div", text),
          ]);
        },
      });
    },
    submitLocalFile() {
      let _this = this;
      let path = this.$api.emergencyMonitorApi.addAssociateDataByLocal + this.taskID;
      let param = {
        images: this.selectFilePath,
        level: this.uploadDataObj.fileLevel,
        path: this.uploadDataObj.uploadfolderPath,
      };
      _this.loading('正在上传数据，请稍后哦~"');
      this.http.post(path, param).then((res) => {
        Spin.hide();
        if (res.data.success) {
          this.$Message.info("上传成功~");
          //刷新目录树
          this.getTreeDataList();
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },

    handleEdit(row, index) {
      this.channel = row.channel;
      this.editIndex = index;
      // console.log(row, "row");
      // console.log(index, "index");
    },
    customerAreaChange(item) {
      this.customerArea = item;
    },

    // @on-open-change="regionSelectedChange1"
    // regionSelectedChange1(item) {
    //   if (item) return;
    //   if (this.satelliteSelected.length !== 0) {
    //     this.refreshTreeDataByReion();
    //     this.refreshTreeDataBySatellite();
    //   } else {
    //     this.refreshTreeDataByReion();
    //   }
    // },
    // 根据区域选择刷新目录树F
    // refreshTreeDataByReion() {
    //   let path = this.$api.emergencyMonitorApi.getTreeDataList;
    //   let params = {
    //     taskId: this.taskID,
    //     region: this.regionSelected.join("#"),
    //   };
    //   this.loading("正在请求目录树，请稍后哦~");
    //   console.log("ip");
    //   this.http.get(path, params).then((res) => {
    //     Spin.hide();
    //     if (res.data.code == 200) {
    //       this.dataList = res.data.data;
    //       // console.log(this.dataList,"ip1")

    //       this.getDataTreeList();
    //     } else {
    //       this.nodataList = res.data.message;
    //     }
    //   });
    // },

    // @on-open-change="satelliteSelectedChange1"
    // satelliteSelectedChange1(item) {
    //   //判断item与satelliteSelected是否有值
    //   // console.log(item, this.satelliteSelected.length);
    //   if (item || this.satelliteSelected.length == 0)
    //     return this.getDataTreeList();
    //   this.refreshTreeDataBySatellite();
    // },
    //根据卫星选择目录树
    // refreshTreeDataBySatellite() {
    //   let path = this.$api.emergencyMonitorApi.getTreeDataList;
    //   let params = {
    //     taskId: this.taskID,
    //     // region: this.regionSelected.join("#"),
    //     // name: this.satelliteSelected.join("#")
    //   };
    //   this.loading("正在请求目录树，请稍后哦~");
    //   this.http.get(path, params).then((res) => {
    //     Spin.hide();
    //     if (res.data.code == 200) {
    //       this.dataList = res.data.data;
    //       // console.log()
    //       this.getSatalliteTreeList();
    //     } else {
    //       this.nodataList = res.data.message;
    //     }
    //   });
    // },
    // //根据卫星种类来渲染目录树
    // getSatalliteTreeList() {
    //   let arr = this.dataList;
    //   // console.log(arr)
    //   let Arr = [];
    //   let expand = true;
    //   let j = -1;
    //   // 处理过程
    //   for (let i = 0; i < arr.length; i++) {
    //     // 先判断  Arr是否为空
    //     arr[i].produceTime = arr[i].produceTime
    //       ? arr[i].produceTime.slice(0, 10)
    //       : "";
    //     if (Arr.length == 0) {
    //       if (arr[i].level.includes("L1")) {
    //         expand = false;
    //       }
    //       let param = {
    //         title: arr[i].produceTime,
    //         expand: true,
    //         contextmenu: true,
    //         children: [
    //           {
    //             title: arr[i].level,
    //             produceTime: arr[i].produceTime,
    //             expand: expand,
    //             contextmenu: true,
    //             children: [
    //               {
    //                 title: arr[i].name,
    //                 produceTime: arr[i].produceTime,
    //                 level: arr[i].level,
    //                 id: arr[i].id,
    //                 meta: arr[i].meta,
    //                 path: arr[i].path,
    //                 dataId: arr[i].dataId,
    //                 region: arr[i].region,
    //                 status: arr[i].status,
    //                 tsakId: arr[i].taskId,
    //                 thumb: arr[i].thumb,
    //                 contextmenu: true,
    //                 expand: expand,
    //               },
    //             ],
    //           },
    //         ],
    //       };
    //       // console.log(param,'--------------------');
    //       // console.log(this.satelliteSelected);
    //       // console.log(param.children[0].children[0].title.split('_')[0].split("-")[0]);
    //       // 判断节点的状态
    //       if (
    //         param.children[0].children[0].status == "normal" &&
    //         this.satelliteSelected.includes(
    //           param.children[0].children[0].title.split("_")[0].split("-")[0]
    //         )
    //       ) {
    //         Arr.push(param);
    //         console.log(Arr, "不为空");
    //         j++;
    //       }
    //     } else {
    //       //Arr 不为空
    //       if (arr[i].produceTime == Arr[j].title) {
    //         //createTime相同
    //         let k = Arr[j].children.length - 1;
    //         if (arr[i].level != Arr[j].children[k].title) {
    //           if (arr[i].level.includes("L1")) {
    //             expand = false;
    //           }
    //           //level不相同
    //           let param = {
    //             title: arr[i].level,
    //             produceTime: arr[i].produceTime,
    //             expand: true,
    //             contextmenu: true,
    //             children: [
    //               {
    //                 title: arr[i].name,
    //                 produceTime: arr[i].produceTime,
    //                 level: arr[i].level,
    //                 id: arr[i].id,
    //                 meta: arr[i].meta,
    //                 path: arr[i].path,
    //                 dataId: arr[i].dataId,
    //                 region: arr[i].region,
    //                 status: arr[i].status,
    //                 tsakId: arr[i].taskId,
    //                 thumb: arr[i].thumb,
    //                 expand: expand,
    //                 contextmenu: true,
    //               },
    //             ],
    //           };
    //           // 判断节点的状态
    //           if (
    //             param.children[0].status == "normal" &&
    //             this.satelliteSelected.includes(
    //               param.children[0].title.split("_")[0].split("-")[0]
    //             )
    //           ) {
    //             Arr[j].children.push(param);
    //           }
    //         } else {
    //           if (arr[i].level.includes("L1")) {
    //             expand = false;
    //           }
    //           let param = {
    //             title: arr[i].name,
    //             produceTime: arr[i].produceTime,
    //             level: arr[i].level,
    //             expand: expand,
    //             id: arr[i].id,
    //             meta: arr[i].meta,
    //             path: arr[i].path,
    //             dataId: arr[i].dataId,
    //             region: arr[i].region,
    //             status: arr[i].status,
    //             tsakId: arr[i].taskId,
    //             thumb: arr[i].thumb,
    //             contextmenu: true,
    //           };
    //           // 判断节点的状态
    //           if (
    //             param.status == "normal" &&
    //             this.satelliteSelected.includes(
    //               param.title.split("_")[0].split("-")[0]
    //             )
    //           ) {
    //             Arr[j].children[k].children.push(param);
    //           }
    //         }
    //       } else {
    //         if (arr[i].level.includes("L1")) expand = false;
    //         //createTime不相同
    //         let param = {
    //           title: arr[i].produceTime,
    //           expand: true,
    //           contextmenu: true,
    //           children: [
    //             {
    //               title: arr[i].level,
    //               produceTime: arr[i].produceTime,
    //               expand: expand,
    //               contextmenu: true,
    //               children: [
    //                 {
    //                   title: arr[i].name,
    //                   produceTime: arr[i].produceTime,
    //                   level: arr[i].level,
    //                   id: arr[i].id,
    //                   meta: arr[i].meta,
    //                   path: arr[i].path,
    //                   dataId: arr[i].dataId,
    //                   region: arr[i].region,
    //                   status: arr[i].status,
    //                   tsakId: arr[i].taskId,
    //                   thumb: arr[i].thumb,
    //                   contextmenu: true,
    //                   expand: expand,
    //                 },
    //               ],
    //             },
    //           ],
    //         };
    //         // 判断节点的状态
    //         if (
    //           param.children[0].children[0].status == "normal" &&
    //           this.satelliteSelected.includes(
    //             param.children[0].children[0].title.split("_")[0].split("-")[0]
    //           )
    //         ) {
    //           Arr.push(param);
    //           j++;
    //         }
    //       }
    //     }
    //   }
    //   // console.log(Arr)
    //   return (this.dataTreeList = Arr);
    //   // console.log(this.dataTreeList,"this.dataTreeList----weixing")
    // },
    // 按关键字搜索
    keySearch(val) {
      console.log(val);
      let path = this.$api.emergencyMonitorApi.getSearchResult;
      let params = {
        taskId: this.taskID,
        fileName: val,
        region: this.regionSelected,
        dataType: this.satelliteSelected,
      };
      this.loading("正在请求目录树，请稍后哦~");
      this.http.get(path, params).then((res) => {
        Spin.hide();
        if (res.data.code == 200) {
          this.dataList = res.data.data;
          this.getDataTreeList();
        } else {
          this.dataTreeList = [];
          this.$Message.error(res.data.message);
        }
      });
    },

    //父组件绘制发生变化时更新区域结果列表和保存参数更新
    async updateRegionResultAndSave() {
      await this.getRegionResult();
      this.saveEmergencyTask();
      this.getCustomerRegionList(); //自定义区域列表
    },
    handleSelectGroup(code, i) {
      // console.log(code);
      // console.log(i);
    },

    changeColor(val) {
      console.log(this.bandColor, "bandcol");
      this.show = !this.show;
      this.show ? (this.active = true) : (this.active = false);
      this.inputStyle = val.bgStyle;
      console.log(this.inputStyle, "this.inputStyle");
      this.getIrgbaData();
    },
    getIrgbaData() {
      let value = this.inputStyle.slice(25, -1).replace(/\s*/g, "").split(",");
      let colorArr = [];
      for (let i = 0; i < value.length; i++) {
        let color = this.hexToRgb(value[i]);
        colorArr.push(color);
      }
      let section = this.calcGroup(0, 255, colorArr.length);
      for (let i = 0; i < colorArr.length; i++) {
        colorArr[i] = [
          Number(section[i]),
          colorArr[i][0],
          colorArr[i][1],
          colorArr[i][2],
          255,
        ];
      }
      this.demColor = colorArr;
      console.log(this.demColor, "ttt");
    },
    hexToRgb(hex) {
      // 16进制色值转换为rgb值
      let rgb = [];
      for (let i = 1; i < 7; i += 2) {
        rgb.push(parseInt("0x" + hex.slice(i, i + 2)));
      }
      return rgb;
    },
    calcGroup(min, max, count) {
      // 计算两个数值间的分段值
      if (count < 2) return [];
      let group = [];
      let span = (max - min) / (count - 1);
      for (let i = 0; i < count; i++) {
        group.push((min + i * span).toFixed(0));
      }
      return group;
    },
    openShow() {
      this.show = !this.show;
      this.show ? (this.active = true) : (this.active = false);
    },
    //自定义区域编号列表
    getCustomerRegionList() {
      let _this = this;
      let path = this.$api.emergencyMonitorApi.queryAssociateAreaBytaskId;
      let param = {
        taskId: this.taskID,
        regionType: 1,
      };
      this.http.get(path, param).then((res) => {
        if (res.data.success) {
          _this.customerRegionList = res.data.data;
        } else {
          // this.$Message.error("自定义区域编号列表查询失败！");
        }
      });
    },
    //数组去重
    unique(arr) {
      let hash = [];
      for (let i = 0; i < arr.length; i++) {
        if (hash.indexOf(arr[i]) === -1) {
          hash.push(arr[i]);
        }
      }
      return hash;
    },
    //获取线框绘制范围
    getLineCoordinate(data) {
      let result = [
        [Number(data.TopLeftLongitude), Number(data.TopLeftLatitude)],
        [Number(data.TopRightLongitude), Number(data.TopRightLatitude)],
        [Number(data.BottomRightLongitude), Number(data.BottomRightLatitude)],
        [Number(data.BottomLeftLongitude), Number(data.BottomLeftLatitude)],
        // [Number(data.TopLeftLongitude), Number(data.TopLeftLatitude)],
      ];
      return result;
    },
    //获取缩略图范围
    getExternalRectangCoordinatelOfImg(imageCoordinate) {
      let long = []; //经度
      let lat = []; //纬度
      imageCoordinate.forEach((element) => {
        long.push(element[0]);
        lat.push(element[1]);
      });
      long = this.unique(long);
      lat = this.unique(lat);
      let minX = Math.min(...long);
      let minY = Math.min(...lat);
      let maxX = Math.max(...long);
      let maxY = Math.max(...lat);
      //绘制缩略图需要四个点坐标  绘制线框需要5个点坐标
      let result = [
        [minX, maxY],
        [maxX, maxY],
        [maxX, minY],
        [minX, minY],
      ];
      return result;
    },

    //缩放至最佳比例尺
    showToCenter(coordinates) {
      // 计算 并 移动到中心点
      let minGlobalX = 180,
        minGlobalY = 90,
        maxGlobalX = -180,
        maxGlobalY = -90;

      for (let lineDatas of coordinates) {
        for (var i = 0; i < lineDatas.length; i++) {
          let gLineData = lineDatas[i];
          if (gLineData.length <= 0) continue;

          for (let j = 0; j < gLineData.length; j++) {
            if (minGlobalX > parseFloat(gLineData[j][0])) {
              minGlobalX = parseFloat(gLineData[j][0]);
            }
            if (maxGlobalX < parseFloat(gLineData[j][0])) {
              maxGlobalX = parseFloat(gLineData[j][0]);
            }
            if (minGlobalY > parseFloat(gLineData[j][1])) {
              minGlobalY = parseFloat(gLineData[j][1]);
            }
            if (maxGlobalY < parseFloat(gLineData[j][1])) {
              maxGlobalY = parseFloat(gLineData[j][1]);
            }
          }
        }
      }

      if (
        minGlobalX == 180 &&
        minGlobalY == 90 &&
        maxGlobalX == -180 &&
        maxGlobalY == -90
      ) {
        return;
      }

      let centerGlobalX = 0;
      let centerGlobalY = 0;
      if (maxGlobalX === -180 && minGlobalX === 180) {
        centerGlobalX = 116.4;
        centerGlobalY = 39.9;
      } else {
        centerGlobalX = (minGlobalX + maxGlobalX) / 2;
        centerGlobalY = (minGlobalY + maxGlobalY) / 2;
      }

      let centermoddle = [];
      centermoddle.push(centerGlobalX);
      centermoddle.push(centerGlobalY);
      //视图范围比数据范围大20%
      let viewWidth = 0;
      let viewHeight = 0;
      if (maxGlobalX === -180 && minGlobalX === 180) {
        viewWidth = (minGlobalX - maxGlobalX) * 1.2;
        viewHeight = (minGlobalY - maxGlobalY) * 1.2;
      } else {
        viewWidth = (maxGlobalX - minGlobalX) * 1.2;
        viewHeight = (maxGlobalY - minGlobalY) * 1.2;
      }

      let ratio = Math.sqrt(Math.sqrt(Math.sqrt(2))); //视图范围每扩大或缩小ratio倍，缩放等级对应减少或增加0.125

      let indexX = 6; //初始缩放等级为7
      let zoomBaseX = 5.96; //缩放等级为7时，经度范围为5.96
      if (viewWidth > zoomBaseX) {
        //如果实际范围比基准范围大，基准范围按比例扩大，直至大于实际范围，获取此时缩放等级
        while ((zoomBaseX = zoomBaseX * ratio) < viewWidth) {
          indexX -= 0.125;
        }
      } else {
        //如果实际范围比基准范围小，基准范围按比例缩小，直至小于实际范围，获取此时缩放等级
        while ((zoomBaseX = zoomBaseX / ratio) > viewWidth) {
          indexX += 0.125;
        }
      }

      let indexY = 6; //初始缩放等级为7
      let zoomBaseY = 1.91; //缩放等级为7时，纬度范围为1.91
      if (viewHeight > zoomBaseY) {
        while ((zoomBaseY = zoomBaseY * ratio) < viewHeight) {
          indexY -= 0.125;
        }
      } else {
        while ((zoomBaseY = zoomBaseY / ratio) > viewHeight) {
          indexY += 0.125;
        }
      }

      //在经纬度分别获取的缩放等级中，获取比较小的值作为缩放等级，确保数据能完全显示
      let index = indexX < indexY ? indexX : indexY;
      this.map.flyTo({
        center: centermoddle,
        zoom: index, // 缩放比例
      });
    },

    //imgId 影像id  isShow 影像是否要显示  mapDiv地图，目前地图有卷帘功能，有两个地图
    async getFirstA(imgId, isShow, mapDiv) {
      let _this = this;
      let path = this.$api.emergencyMonitorApi.queryDataWithId + imgId;
      let { data } = await axios.get(path);
      let imgPath = data.data.path + "/" + data.data.name;
      let layerID = "picture" + imgPath;
      if (!isShow) {
        _this.removeLayer(layerID);
        return;
      } else if (mapDiv === "afterMap") {
        _this.removeLayer(layerID);
      } else if (mapDiv === "beforeMap" && _this.map.getLayer(layerID)) {
        //  this.$Message.info("当前地图已添加该影像，请勿重复加载！");
        return;
      }
      let bounds = this.getImageBounds(data.data);
      let tempMap = mapDiv === "beforeMap" ? this.map : this.afterMap;
      tempMap.addLayer({
        id: layerID,
        type: "raster",
        source: {
          type: "image",
          url: data.data.thumb,
          coordinates: bounds,
        },
        paint: {
          "raster-opacity": 1,
        },
      });
      //地图缩放
      // this.showToCenter([[bounds]]);
    },

    //得到L1A影像的显示范围---影像纠偏
    getImageBounds(data) {
      // console.log("1111111111111111",data)
      // console.log("得到L1A影像的显示范围---影像纠偏")
      let bounds = [];
      let envelop = [];
      let dataMeta = "";
      let region = data.region;
      let bound = region.split(",");
      let Arr = [];
      // console.log("3333333",bound)
      for (let i = 1; i < bound.length; i++) {
        if (i < bound.length - 1) {
          for (let j = 0; j < 2; j++) Arr.push(Number(bound[i].trim().split(" ")[j]));
        } else {
          for (let j = 0; j < 2; j++)
            Arr.push(Number(bound[i].replace("))", "").trim().split(" ")[j]));

        }
      }
      if (region) {
        let a = Arr.length;
        bounds = [
          [Arr[a - 2], Arr[a - 1]],
          [Arr[a - 4], Arr[a - 3]],
          [Arr[a - 6], Arr[a - 5]],
          [Arr[a - 8], Arr[a - 7]],
        ];
      } else if (data.meta) {
        dataMeta = this.$x2js.xml2js(data.meta); //xml为需要转换的字符串xml
        envelop = dataMeta.ProductMetaData;
        bounds = this.getLineCoordinate(envelop);
      } else {
        this.$Message.warning("无法确定影像边界");
      }
      return bounds;
    },
    //切片发布
    getInfo(imgPath, isShow, mapDiv) {
      let path = url1 + "/transferPost";
      axios
        .get(path, {
          params: {
            url: "?request=GetImageInfo",
            params: JSON.stringify(imgPath),
          },
        })
        .then((res) => {
          let envelop = res.data[0].envelope;
          let bandCount = res.data[0].band_count;
          let left = envelop.left;
          let right = envelop.right;
          let top = envelop.top;
          let bottom = envelop.bottom;
          // let nodata_value=res.data[0].nodata_value;
          let bounds = [
            [left, bottom],
            [right, top],
          ];
          let kind = "";
          if (bandCount == 1) {
            kind = "dem";
            //externalNodataValue=[0];
          } else {
            kind = "trueColor";
          }

          let bandMap = [4, 3, 2];
          let stretch = {
            kind: "standardDeviation",
            percent: 0.2,
          };
          let layerID = "picture" + imgPath;
          if (!isShow) {
            this.removeLayer(layerID);
            return;
          } else if (mapDiv === "afterMap") {
            this.removeLayer(layerID);
          } else if (mapDiv === "beforeMap" && this.map.getLayer(layerID)) {
            // this.$Message.info("当前地图已添加该影像，请勿重复加载！");
            return;
          }

          let info = {
            info: [
              {
                path: `${imgPath}`,
                style: {
                  kind: `${kind}`,
                  bandMap: bandMap,
                  stretch: stretch,
                },
              },
            ],
          };

          let stretch1 = {
            kind: this.styleLaterStretch,
            percent: this.styleLaterPercent,
            // externalNodataValue:externalNodataValue
          };
          let info1 = {
            info: [
              {
                path: `${imgPath}`,
                style: {
                  kind: `${kind}`,
                  bandMap: this.styleLaterBands,
                  stretch: stretch1,
                },
              },
            ],
          };
          console.log(this.styleLaterPercent, "this.styleLaterPercent");
          console.log(this.styleLaterStretch, "styleLaterStretch");
          console.log(this.styleLaterBands, "styleLaterBands");
          if (this.styleLaterPercent == -1) {
            const source = {
              type: "raster",
              bounds: [...bounds[0], ...bounds[1]],
              tiles: [
                `${url3}/v1?request=GetTile&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&info=${encodeURIComponent(
                  JSON.stringify(info)
                )}`,
              ],
              tileSize: 256, // 返回图片大小默认是256
            };
            let tempMap = mapDiv === "beforeMap" ? this.map : this.afterMap;
            tempMap.addLayer({
              id: layerID,
              type: "raster",
              source: source,
              paint: {
                "raster-opacity": 1,
              },
            });
          } else {
            const source = {
              type: "raster",
              bounds: [...bounds[0], ...bounds[1]],
              tiles: [
                `${url3}/v1?request=GetTile&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&info=${encodeURIComponent(
                  JSON.stringify(info1)
                )}`,
              ],
              tileSize: 256, // 返回图片大小默认是256
            };
            let tempMap = mapDiv === "beforeMap" ? this.map : this.afterMap;
            tempMap.addLayer({
              id: layerID,
              type: "raster",
              source: source,
              paint: {
                "raster-opacity": 1,
              },
            });
          }

          // const source = {
          //   type: "raster",
          //   bounds: [...bounds[0], ...bounds[1]],
          //   tiles: [
          //     `${url3}/v1?request=GetTile&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&info=${encodeURIComponent(
          //       JSON.stringify(info)
          //     )}`,
          //   ],
          //   tileSize: 256, // 返回图片大小默认是256
          // };
          // let tempMap = mapDiv === "beforeMap" ? this.map : this.afterMap;
          // tempMap.addLayer({
          //   id: layerID,
          //   type: "raster",
          //   source: source,
          //   paint: {
          //     "raster-opacity": 1,
          //   },
          // });
          // this.map.fitBounds(bounds, {
          //   linear: true,
          //   padding: { top: 25, bottom: 25, left: 25, right: 25 },
          // });
        });
    },

    //shp矢量修改
    async shpColorView() {
      this.shpColorShow = true;
      let path1 = this.$api.emergencyMonitorApi.queryDataWithId + this.currentTreeNode.id;
      let { data } = await axios.get(path1);
      this.shpData = data.data;
    },
    shpColorOk() {
      this.getRegionByShpColor(this.shpData);
      this.shpColorShow = false;
    },
    //元数据缩放到图层
    async fixScaleMapL1A() {
      console.log("//元数据缩放到图层//元数据缩放到图层")
      const path =
        this.$api.emergencyMonitorApi.queryDataWithId + this.currentTreeNode.id;
      let { data } = await axios.get(path);
      let bounds = this.getImageBounds(data.data);

      this.showToCenter([[bounds]]);
    },
    //瓦片数据定位
    fixScaleMapTile() {
      let imgPath = this.currentTreeNode.path + "/" + this.currentTreeNode.title;
      let path = url1 + "/transferPost";
      axios
        .get(path, {
          params: {
            url: "?request=GetImageInfo",
            params: JSON.stringify([imgPath]),
          },
        })
        .then((res) => {
          console.log(res.data, "1");
          let envelop = res.data[0].envelope;
          console.log(envelop, "1");
          let left = envelop.left;
          let right = envelop.right;
          let top = envelop.top;
          let bottom = envelop.bottom;
          let bounds = [
            [left, bottom],
            [right, top],
          ];
          this.map.fitBounds(bounds, {
            linear: true,
            padding: { top: 25, bottom: 25, left: 25, right: 25 },
          });
        });
    },

    //shp数据缩放到图层
    fixScaleMapShp() {
      let layerId = this.currentTreeNode.id + "";
      // this.removeLayer(layerId);
      let path = this.$api.taskManageApi.disasterShpFileQuery;
      let param = {
        fileName: this.currentTreeNode.path + "/" + this.currentTreeNode.title,
      };
      this.http.post(path, param).then((res) => {
        if (res.data.code == 200) {
          let shpDataRegion = res.data.data;
          console.log(shpDataRegion, "shpDataRegion");
          //  this.$emit("drawGeometry", shpDataRegion.features[0]);
          // let dataLength=shpDataRegion.features.length;
          // let minShp=shpDataRegion.features[0].geometry.coordinates;
          // let maxShp=shpDataRegion.features[dataLength-1].geometry.coordinates;
          // console.log(minShp,"minShp");
          // console.log(maxShp,"minShp");
          this.showToCenter(shpDataRegion.features[0].geometry.coordinates);
        }
      });
    },

    drawGeometry(geojson, layerId) {
      let shpType = geojson.features[0].geometry.type;
      let self = this;

      self.map.addSource(layerId, {
        type: "geojson",
        // data: {
        //   type: "Feature",
        //   geometry: geojson,
        // },
        data: geojson,
      });
      console.log(shpType, "shpType");
      if (shpType == "Point") {
        self.map.addLayer({
          id: layerId,
          type: "circle",
          source: layerId,
          layout: {},
          paint: {
            "circle-opacity": 0.5,
            "circle-radius": 6,
            "circle-color": "#B42222",
          },
        });
      } else if (shpType.includes("Line")) {
        self.map.addLayer({
          id: layerId,
          type: "line",
          source: layerId,
          layout: {
            "line-cap": "round",
          },
          paint: {
            "line-opacity": 0.5,
            "line-color": "#B42222",
            "line-width": 8,
          },
        });
      } else {
        self.map.addLayer({
          id: layerId,
          type: "fill",
          source: layerId,
          layout: {},
          paint: {
            "fill-color": "#088",
            "fill-opacity": 0.5,
          },
        });
      }

      //this.showToCenter(geojson.features[0].geometry.coordinates);
    },

    //样式设置
    // 样式
    async styleOfTreeData() {
      let imgPath = this.currentTreeNode.path + "/" + this.currentTreeNode.title;
      const path = url1 + "/transferPost";
      axios
        .get(path, {
          params: {
            url: "?request=GetImageInfo",
            params: JSON.stringify([imgPath]),
          },
        })
        .then((res) => {
          let bands = res.data[0].bands;
          let imgBands = [];
          let imgBandsMin = [];
          let imgBandsMax = [];
          if (res.data[0]) {
            for (let i = 0; i < bands.length; i++) {
              imgBands.push(bands[i].name);
              imgBandsMin.push(bands[i].min);
              imgBandsMax.push(bands[i].max);
            }

            this.bandCount = res.data[0].band_count;
            this.bandOptions = imgBands.map((d) => {
              return { label: d, value: d };
            });
          }
        });
      this.styleShow = true;
    },
    //单波段
    colorApplication() {
      let imgpath = this.currentTreeNode.path + "/" + this.currentTreeNode.title;
      let layerID = "picture" + imgpath;
      this.removeLayer(layerID);
      const path = url1 + "/transferPost";
      axios
        .get(path, {
          params: {
            url: "?request=GetImageInfo",
            params: JSON.stringify([imgpath]),
          },
        })
        .then((res) => {
          let envelop = res.data[0].envelope;
          let left = envelop.left;
          let right = envelop.right;
          let top = envelop.top;
          let bottom = envelop.bottom;
          let bounds = [
            [left, bottom],
            [right, top],
          ];
          if (res.data[0] != null) {
            this.bands = res.data[0].bands;
          }
          let stretchStyle = this.stretchStyle;
          this.styleLaterStretch = stretchStyle;
          console.log(this.styleLaterStretch, "this.styleLaterStretch");
          let bandCount = this.bandCount;
          let kind = "";
          let lut = [];
          if (bandCount == 1) {
            kind = "dem";
            for (let i = 0; i < this.demColor.length; i++) {
              lut.push(this.demColor[i]);
            }
          } else {
            kind = "trueColor";
          }
          let bandMap = [];
          if (this.styleBands.length === 0) {
            let styleBands = ["B4", "B3", "B2"];
            bandMap = styleBands.map(function (d) {
              return Number(d.replace("B", ""));
            });
          } else {
            bandMap = this.styleBands.map(function (d) {
              return Number(d.replace("B", ""));
            });
          }
          this.styleLaterBands = bandMap;
          console.log(this.styleLaterBands, "this.styleLaterBands=bandMap");
          let percent = (this.percent / 100).toFixed(2);
          this.styleLaterPercent = percent;
          console.log(this.styleLaterPercent, " this.styleLaterPercent=percent;");
          let stretch = {};

          if (stretchStyle != "minimumMaximum") {
            stretch = {
              kind: `${stretchStyle}`,
              percent: percent,
            };
          } else {
            stretch = {
              kind: `${stretchStyle}`,
              minimum: -1000,
              maximum: 8000,
            };
          }
          console.log(stretch, "stretch");
          let info = {
            info: [
              {
                path: `${imgpath}`,
                style: {
                  kind: `${kind}`,
                  lut: lut,
                  bandMap: bandMap,
                  // bandCount:bandCount,
                  stretch: stretch,
                },
              },
            ],
          };
          const source = {
            type: "raster",
            bounds: [...bounds[0], ...bounds[1]],
            tiles: [
              `${url3}/v1?request=GetTile&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&info=${encodeURIComponent(
                JSON.stringify(info)
              )}`,
            ],
            tileSize: 256, // 返回图片大小默认是256
          };
          this.map.addLayer({
            id: layerID,
            type: "raster",
            source: source,
            paint: {
              "raster-opacity": 1,
            },
          });
          this.percent = 20;
        });
      this.styleShow = false;
      //清除参数
    },
    //申请应用
    applicationTile() {
      let imgpath = this.currentTreeNode.path + "/" + this.currentTreeNode.title;
      let layerID = "picture" + imgpath;
      this.removeLayer(layerID);
      const path = url1 + "/transferPost";
      axios
        .get(path, {
          params: {
            url: "?request=GetImageInfo",
            params: JSON.stringify([imgpath]),
          },
        })
        .then((res) => {
          let envelop = res.data[0].envelope;
          let left = envelop.left;
          let right = envelop.right;
          let top = envelop.top;
          let bottom = envelop.bottom;
          let bounds = [
            [left, bottom],
            [right, top],
          ];
          if (res.data[0] != null) {
            this.bands = res.data[0].bands;
          }
          let stretchStyle = this.stretchStyle;
          this.styleLaterStretch = stretchStyle;
          console.log(this.styleLaterStretch, "this.styleLaterStretch");
          let bandCount = this.bandCount;
          let kind = "";
          if (bandCount == 1) {
            kind = "dem";
          } else {
            kind = "trueColor";
          }
          let bandMap = [];
          if (this.styleBands.length === 0) {
            let styleBands = ["B4", "B3", "B2"];
            bandMap = styleBands.map(function (d) {
              return Number(d.replace("B", ""));
            });
          } else {
            bandMap = this.styleBands.map(function (d) {
              return Number(d.replace("B", ""));
            });
          }
          this.styleLaterBands = bandMap;
          console.log(this.styleLaterBands, "this.styleLaterBands=bandMap");
          let percent = (this.percent / 100).toFixed(2);
          this.styleLaterPercent = percent;
          console.log(this.styleLaterPercent, " this.styleLaterPercent=percent;");
          let stretch = {};

          if (stretchStyle != "minimumMaximum") {
            stretch = {
              kind: `${stretchStyle}`,
              percent: percent,
            };
          } else {
            stretch = {
              kind: `${stretchStyle}`,
              minimum: -1000,
              maximum: 8000,
            };
          }
          console.log(stretch, "stretch");
          let info = {
            info: [
              {
                path: `${imgpath}`,
                style: {
                  kind: `${kind}`,
                  bandMap: bandMap,
                  // bandCount:bandCount,
                  stretch: stretch,
                },
              },
            ],
          };
          const source = {
            type: "raster",
            bounds: [...bounds[0], ...bounds[1]],
            tiles: [
              `${url3}/v1?request=GetTile&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&info=${encodeURIComponent(
                JSON.stringify(info)
              )}`,
            ],
            tileSize: 256, // 返回图片大小默认是256
          };
          this.map.addLayer({
            id: layerID,
            type: "raster",
            source: source,
            paint: {
              "raster-opacity": 1,
            },
          });
          // this.map.fitBounds(bounds, {
          //   linear: true,
          //   padding: { top: 25, bottom: 25, left: 25, right: 25 },
          // });
          // this.stretchStyle = "";
          //  this.styleBands=[];
          this.percent = 20;
        });
      this.styleShow = false;
      //清除参数
    },

    //取消样式
    deleteStyle() {
      this.styleShow = false;
    },
    //切换rgb样式
    settingRgb() {
      this.rgbSettingShow = true; //Rgb设置
      this.strSettingShow = false; //拉伸设置
      this.coloSettingShow = false; //色彩映射设置
    },
    //切换Stretch样式
    settingStrecth() {
      this.rgbSettingShow = false; //;Rgb设置
      this.strSettingShow = true; //拉伸设置
      this.coloSettingShow = false; //色彩映射设置
    },
    // settingColor() {
    //   (this.rgbSettingShow = false), //Rgb设置
    //     (this.strSettingShow = false), //拉伸设置
    //     (this.coloSettingShow = true); //色彩映射设置
    // },

    drawRectangle() {
      this.$emit("drawRectangle");
    },
    drawPloy() {
      this.$emit("drawPoly");
    },
    // 获取 数据目录树  原始
    getTreeDataList() {
      let path = this.$api.emergencyMonitorApi.getTreeDataList;
      let params = {
        taskId: this.taskID,
      };
      this.loading("正在请求目录树，请稍后哦~");
      this.http.get(path, params).then((res) => {
        Spin.hide();
        if (res.data.code == 200) {
          this.dataList = res.data.data;
          this.getDataTreeList();
        }
      });
    },
    // 处理  数据目录树 最终
    getDataTreeList() {
      let arr = this.dataList;
      console.log(arr, "arr");
      let Arr = [];
      let expand = true;
      let j = -1;
      // 处理过程

      for (let i = 0; i < arr.length; i++) {
        // 先判断  Arr是否为空
        arr[i].produceTime = arr[i].produceTime ? arr[i].produceTime.slice(0, 10) : "";
        if (Arr.length == 0) {
          if (arr[i].level.includes("L1")) {
            expand = false;
          }
          let param = {
            title: arr[i].produceTime,
            expand: true,
            contextmenu: true,
            children: [
              {
                title: arr[i].level,
                produceTime: arr[i].produceTime,
                expand: expand,
                contextmenu: true,
                children: [
                  {
                    title: arr[i].name,
                    produceTime: arr[i].produceTime,
                    level: arr[i].level,
                    id: arr[i].id,
                    meta: arr[i].meta,
                    path: arr[i].path,
                    dataId: arr[i].dataId,
                    region: arr[i].region,
                    status: arr[i].status,
                    tsakId: arr[i].taskId,
                    thumb: arr[i].thumb,
                    contextmenu: true,
                    expand: expand,
                  },
                ],
              },
            ],
          };
          // 判断节点的状态
          if (param.children[0].children[0].status == "normal") {
            Arr.push(param);
            j++;
          }
        } else {
          //Arr 不为空
          if (arr[i].produceTime == Arr[j].title) {
            //createTime相同
            let k = Arr[j].children.length - 1;
            if (arr[i].level != Arr[j].children[k].title) {
              if (arr[i].level.includes("L1")) {
                expand = false;
              }
              //level不相同
              let param = {
                title: arr[i].level,
                produceTime: arr[i].produceTime,
                expand: true,
                contextmenu: true,
                children: [
                  {
                    title: arr[i].name,
                    produceTime: arr[i].produceTime,
                    level: arr[i].level,
                    id: arr[i].id,
                    meta: arr[i].meta,
                    path: arr[i].path,
                    dataId: arr[i].dataId,
                    region: arr[i].region,
                    status: arr[i].status,
                    tsakId: arr[i].taskId,
                    thumb: arr[i].thumb,
                    expand: expand,
                    contextmenu: true,
                  },
                ],
              };
              // 判断节点的状态
              if (param.children[0].status == "normal") {
                Arr[j].children.push(param);
              }
            } else {
              if (arr[i].level.includes("L1")) {
                expand = false;
              }
              let param = {
                title: arr[i].name,
                produceTime: arr[i].produceTime,
                level: arr[i].level,
                expand: expand,
                id: arr[i].id,
                meta: arr[i].meta,
                path: arr[i].path,
                dataId: arr[i].dataId,
                region: arr[i].region,
                status: arr[i].status,
                tsakId: arr[i].taskId,
                thumb: arr[i].thumb,
                contextmenu: true,
              };
              // 判断节点的状态
              if (param.status == "normal") {
                Arr[j].children[k].children.push(param);
              }
            }
          } else {
            if (arr[i].level.includes("L1")) expand = false;
            //createTime不相同
            let param = {
              title: arr[i].produceTime,
              expand: true,
              contextmenu: true,
              children: [
                {
                  title: arr[i].level,
                  produceTime: arr[i].produceTime,
                  expand: expand,
                  contextmenu: true,
                  children: [
                    {
                      title: arr[i].name,
                      produceTime: arr[i].produceTime,
                      level: arr[i].level,
                      id: arr[i].id,
                      meta: arr[i].meta,
                      path: arr[i].path,
                      dataId: arr[i].dataId,
                      region: arr[i].region,
                      status: arr[i].status,
                      tsakId: arr[i].taskId,
                      thumb: arr[i].thumb,
                      contextmenu: true,
                      expand: expand,
                    },
                  ],
                },
              ],
            };
            // 判断节点的状态
            if (param.children[0].children[0].status == "normal") {
              Arr.push(param);
              j++;
            }
          }
        }
      }
      this.dataTreeList = Arr;
      // console.log(this.dataTreeList,"this.dataTreeList")
    },

    hideDrawer() {
      this.$emit("leftDrawerHide");
    },
    // 切换 设置
    settingChange() {
      this.dataSettingShow = true;
      this.dataTreeShow = false;
    },
    // 切换 数据目录
    dataTreeChange() {
      this.dataSettingShow = false;
      this.dataTreeShow = true;
    },

    // 查询接口
    getDisasterInfoById() {
      let path = this.$api.emergencyMonitorApi.disasterTaskIdQuery + `${this.taskID}`;
      this.http.get(path).then((res) => {
        if (res.data.code == 200) {
          let TaskData = res.data.data;
          this.taskName = TaskData.name;
          this.taskTime = TaskData.createTime;
          this.TaskAddress = TaskData.regionName;
          this.TaskDisasterType = TaskData.disasterName;
          this.regionProviceCode = TaskData.regionCode;
          this.disasterId = TaskData.disasterId;

          // 新增卫星、传感器和级别显示

          if (TaskData.params) {
            this.satellites = TaskData.params.satellite;
            this.sensors = TaskData.params.sensor;
            this.productLevel = TaskData.params.level;
          }
          this.$emit("taskName", this.taskName);
          // 获取city
          this.getCityByProviceCode();

          //获取产品列表
          this.getproductList();

          //定位省区
          let code = this.regionProviceCode + "0000";
          // this.drawGeometryByCode(code, 0);

          //获取区域结果
          this.getRegionResult();

          //获取使用过数据的框显示
          // this.initProductData();

          //获取查询时间
          // this.getQueryTime();
          // this.getSatelleResult();
        }
      });
    },
    // 获取city
    getCityByProviceCode() {
      let _this = this;
      let path =
        this.$api.taskManageApi.regionQueryCityByProvince + `${this.regionProviceCode}`;
      let cityNum;
      let cityTotal = {};
      let countyTotal = {};
      let countyType = [];
      this.http.get(path).then((res) => {
        if (res.data.code == 200) {
          _this.regionCascader = [];
          let CityData = res.data.data;
          cityNum = CityData.length;
          for (let i = 0; i < cityNum; i++) {
            let num = countyType.length;
            let tempdata1 = {
              value: CityData[i].code,
              label: CityData[i].name,
              loading: false,
              number: i,
              children: [],
            };
            _this.regionCascader.push(tempdata1);
          }
        }
      });
    },

    // 获取县
    loadRegionData(item, callback) {
      let _this = this;
      item.loading = true;
      let path =
        this.$api.emergencyMonitorApi.regionQueryAreaByCityCode + `${item.value}`;
      let countyType = {};
      this.http.get(path).then((res) => {
        if (res.data.code == 200) {
          let coutyData = res.data.data;
          let tempData = {};
          for (let j = 0; j < coutyData.length; j++) {
            tempData = {
              value: coutyData[j].code,
              label: coutyData[j].name,
            };
            this.regionCascader[item.number].children.push(tempData);
          }
        }
        item.loading = false;
        callback();
      });
      // }
      // else{
      //   return;
      // }
    },

    //获取产品列表
    getproductList() {
      this.productList = [];
      let path = this.$api.taskManageApi.disasterQueryProductions + `${this.disasterId}`;

      this.http.get(path).then((res) => {
        if (res.data.code == 200) {
          let ProductData = res.data.data;
          let tempDataL4Lst = [];
          let tempDataL5Lst = [];
          let tempDataL6Lst = [];
          let tempDataL4 = [];
          let tempDataL5 = [];
          let tempDataL6 = [];
          for (let i = 0; i < ProductData.length; i++) {
            if (ProductData[i].prolevel == "正射") {
              tempDataL4 = {
                label: ProductData[i].productionName,
                productionTag: ProductData[i].productionTag,
                satellite: ProductData[i].satellite,
                sensor: ProductData[i].sensor,
                isCheck: false,
              };
            } else if (ProductData[i].prolevel == "要素遥感监测") {
              tempDataL5 = {
                label: ProductData[i].productionName + "(要素遥感监测)",
                productionTag: ProductData[i].productionTag,
                satellite: ProductData[i].satellite,
                sensor: ProductData[i].sensor,
                isCheck: false,
              };
            } else {
              tempDataL6 = {
                label: ProductData[i].productionName + "(应急风险监测)",
                productionTag: ProductData[i].productionTag,
                satellite: ProductData[i].satellite,
                sensor: ProductData[i].sensor,
                isCheck: false,
              };
            }
            // let tempData = {
            //   label: ProductData[i].productionName,
            //   productionTag: ProductData[i].productionTag,
            //   satellite: ProductData[i].satellite,
            //   sensor: ProductData[i].sensor,
            //   isCheck: false,
            // };
            //this.productList.push(tempData);
            if (tempDataL4.length != 0) {
              tempDataL4Lst.push(tempDataL4);
            } else if (tempDataL5.length != 0) {
              tempDataL5Lst.push(tempDataL5);
            } else if (tempDataL6.length != 0) {
              tempDataL6Lst.push(tempDataL6);
            }
          }
          this.productList = this.productList
            .concat(tempDataL6Lst)
            .concat(tempDataL5Lst)
            .concat(tempDataL4Lst);
          // this.productList.push(tempDataL4Lst);
          // this.productList.push(tempDataL5Lst);
          // this.productList.push(tempDataL6Lst);
        }
      });
    },

    drawGeometryByCode(code, type) {
      let _this = this;
      // let path = this.$api.taskManageApi.queryFeature;

      // let param = {
      //   collectionName: "area_info",
      //   orderColName: "",
      //   queryConditionList: [
      //     {
      //       compareOp: "=",
      //       fieldName: "type",
      //       fieldValue: type,
      //       relationNextOne: "AND",
      //     },
      //     {
      //       compareOp: "=",
      //       fieldName: "code",
      //       fieldValue: code,
      //     },
      //   ],
      //   queryResultList: ["wkb_geometry"],
      // };

      // _this.http.post(path, param).then((res) => {
      //   let data = res.data.data;
      //   if (res.data.code == 0) {
      //     let geometry = [];
      //     if (data.data.length < 1) {
      //       _this.$Message.info("获取范围失败");
      //       return;
      //     }
      //     geometry.push(data.data[0].geometry);
      //     _this.$emit("drawGeometry", geometry);
      //   } else {
      //     _this.$Message.error(res.data.message);
      //   }
      // });
      let path = this.$api.riskMonitorApi.queryFeature + code;
      _this.http.get(path).then((res) => {
        if (res.data.success) {
          let data = JSON.parse(res.data.data);
          console.log(data);
          if (data.length < 1) return _this.$Message.info("获取范围失败");
          _this.$emit("drawGeometry", data);
        } else {
          _this.$Message.error(res.data.message);
        }
      });
    },

    //获取区域结果
    async getRegionResult() {
      this.currentRegionList = [];
      this.regionResultList = [];
      this.regionResultIDList = [];
      //设置查询区域
      let tempdata = {
        geoType: "region",
        geoValue: this.regionProviceCode,
      };
      this.currentRegionList.push(tempdata);
      this.regionResultList.push(this.TaskAddress);

      // let path =
      //   this.$api.emergencyMonitorApi.queryAssociateAreaBytaskId +
      //   `${this.taskID}`;
      let path = this.$api.emergencyMonitorApi.queryAssociateAreaBytaskId;
      let param = {
        taskId: this.taskID,
      };
      this.http.get(path, param).then((res) => {
        if (res.data.code == 200) {
          let regionResultList = res.data.data;
          this.taskAreaList = regionResultList;
          for (let i = 0; i < regionResultList.length; i++) {
            let region = regionResultList[i];
            this.regionResultList.push(region.regionName);
            console.log(this.regionResultList);
            let tempRegionData = {};
            if (!region.regionWkt) {
              tempRegionData = {
                geoType: "region",
                geoValue: region.regionCode,
              };
            } else {
              tempRegionData = {
                geoType: "polygon",
                geoValue: region.regionWkt,
                code: region.regionCode,
              };
            }
            this.currentRegionList.push(tempRegionData);

            // 保存ID
            let tempData1 = {
              regionName: region.regionName,
              regionID: region.id,
            };

            this.regionResultIDList.push(tempData1);
            console.log(this.regionResultIDList);
          }
        }
      });
    },
    //获取卫星数据
    getSatelleData() {
      this.satelliteResultNameList = [];
      let path = this.$api.emergencyMonitorApi.getSatelleData;
      let param = {
        taskId: this.taskID,
      };
      this.http.get(path, param).then((res) => {
        if (res.data.success) {
          let result = res.data.data;
          result.forEach((item) => {
            this.satelliteResultNameList.push(item.satellite);
          });
        }
      });
    },

    //获取卫星name结果
    // async getSatelleResult() {
    //   this.satelliteResultNameList = [];
    //   let path = this.$api.emergencyMonitorApi.getTreeDataList;
    //   let param = {
    //     taskId: this.taskId,
    //   };
    //   this.http.get(path, param).then((res) => {
    //     if (res.data.code == 200) {
    //       let satelliteResultList = res.data.data;
    //       // console.log(satelliteResultList)
    //       for (let i = 0; i < satelliteResultList.length; i++) {
    //         if (satelliteResultList[i].status == "normal") {
    //           let satalliteName = satelliteResultList[i];
    //           // console.log(satalliteName);
    //           this.satelliteResultNameList.push(
    //             satalliteName.name.split("_")[0].split("-")[0]
    //           );
    //         }
    //       }
    //       this.satelliteResultNameList = new Set(this.satelliteResultNameList);
    //     }
    //   });
    // },

    //矢量文件操作
    selecrShpPath() {
      this.showPushTaskZtreeModal = true;
      this.pushTaskMenu();
    },
    pushTaskMenu(type) {
      let treeObj = $.fn.zTree.getZTreeObj("pushTaskTree");
      if (treeObj != null) {
        var nodes = treeObj.getNodes();
        for (var i = nodes.length - 1; i >= 0; i--) {
          treeObj.removeNode(nodes[i]);
        }
      }

      //1 共享 2 用户 3 推送任务扫描
      let path = this.$api.emergencyMonitorApi.fileRootPath + 1;

      this.pushTaskMenuSetting(path);
    },
    // 应急推送任务扫描目录、生产目录Ztree设置
    pushTaskMenuSetting(urlPath) {
      let checkType = { Y: "", N: "" }; //父与子的关联去掉
      let setting = {
        check: {
          enable: true,
          nocheckInherit: false,
          chkboxType: checkType,
        },
        data: {
          simpleData: {
            enable: true,
          },
        },
        callback: {
          beforeClick: this.beforeClick,
          onClick: this.zTreeOnClick,
          onCheck: this.zTreePushTaskOnCheck,
          onExpand: this.zTreeOnClick,
        },
      };

      this.http.get(urlPath).then((res) => {
        let data = res.data;
        if (data.success == true) {
          $.fn.zTree.init($("#pushTaskTree"), setting, data.data);
        }
      });
    },

    zTreePushTaskOnCheck(event, treeId, treeNode) {
      var treeObj = $.fn.zTree.getZTreeObj(treeId),
        nodes = treeObj.getCheckedNodes(true);

      // if (!treeNode.isParent) {
      //   this.$Message.error("请选择文件夹！");
      //   treeNode.checked = false;
      //   treeObj.updateNode(treeNode);
      //   return;
      // }
      if (nodes.length > 1) {
        //限制单个文件夹
        this.$Message.error("矢量数据只能选择一个！");
        treeNode.checked = false;
        treeObj.updateNode(treeNode);
        return;
      }
    },
    zTreeOnClick(event, treeId, treeNode) {
      let path = this.$api.taskManageApi.getFileListByPath;
      let param = {
        path: treeNode.id,
      };
      var treeObj = $.fn.zTree.getZTreeObj(treeId);
      var node = treeObj.getNodeByParam("id", treeNode.id);
      treeObj.selectNode(node);
      let sNode = treeObj.getSelectedNodes();
      if (sNode.length > 0) {
        let zAsync = sNode[0].zAsync;
        treeObj.reAsyncChildNodes(treeNode, "refresh");
        if (zAsync) {
        } else {
          this.http.get(path, param).then((res) => {
            let data = res.data;
            if (data.success == true) {
              treeNode.halfCheck = false;
              treeObj.addNodes(treeNode, data.data, false);
              sNode[0].zAsync = true;
            }
          });
        }
      }
    },
    async pushTaskMenuOk() {
      let treeObj = $.fn.zTree.getZTreeObj("pushTaskTree"),
        nodes = treeObj.getCheckedNodes(true);
      let tempNode = "";
      let info = "";
      for (var index in nodes) {
        tempNode = nodes[index];
        if (info == "") {
          info = tempNode.id;
        } else {
          info += ";" + tempNode.id;
        }
      }
      if (info.length < 3) {
        this.$Message.error("请选择矢量(.shp)文件！");
        this.pushTaskReset();
      } else {
        let shpFileSufix = info.substr(info.length - 3, info.length);
        if (shpFileSufix.toLowerCase() == "shp") {
          this.shpPath = info;

          let arr = info.split("/");
          let index = arr[arr.length - 1].indexOf(".");
          let shpName = arr[arr.length - 1].substring(0, index);
          let path = this.$api.taskManageApi.disasterShpFileQuery;
          let param = {
            fileName: this.shpPath,
          };
          let res = await this.http.post(path, param);
          if (res.data.code == 200) {
            let shpDataRegion = res.data.data;
            let tempdata1 = {
              geoType: "",
              geoValue: "",
              code: "",
            };

            tempdata1["geoType"] = "polygon";
            tempdata1["geoValue"] = shpDataRegion;
            this.currentRegionList.push(tempdata1);

            //添加关联区域到数据库里
            let wkt = await this.geoJsonToWkt(shpDataRegion.features[0].geometry);
            let path1 = this.$api.taskManageApi.addAssociateArea;
            let param1 = {
              disasterTaskId: this.taskID,
              regionName: shpName,
              regionType: 1,
              regionWkt: wkt,
              taskSource: 10,
            };
            this.http.post(path1, param1).then((res) => {
              if (res.data.code == 200) {
                //获取区域结果ID
                this.regionResultList.push(shpName);
                this.getRegionResultId();
                // 绘制区域
                this.$emit("drawGeometry", shpDataRegion.features[0]);
                this.$Message.success("添加成功");
                this.$emit("refreshRegion");
              } else {
                //获取区域结果ID
                // this.getRegionResultId();
                this.$Message.error("添加失败");
              }
            });
          } else {
            this.$Message.error("读取矢量数据失败！！");
          }

          // 绘制区域
          // this.drawGeometry(this.currentImportantRegion.geometries);
        } else {
          this.$Message.error("请选择矢量(.shp)文件！");
        }
        this.pushTaskReset();
      }
    },
    async geoJsonToWkt(geojson) {
      let wkt = "";
      let path = this.$api.emergencyMonitorApi.geoJsonToWkt;
      await this.http.post(path, geojson).then((res) => {
        if (res.data.success) {
          wkt = res.data.data;
        } else {
          this.$Message.error("wkt转换失败");
        }
      });
      return wkt;
    },
    pushTaskMenuCancel() {
      this.pushTaskReset();
    },
    pushTaskReset() {
      var treeObj;
      this.showPushTaskZtreeModal = false;
      treeObj = $.fn.zTree.getZTreeObj("pushTaskTree");
      if (treeObj == null) return;

      var nodes = treeObj.getNodes();
      for (var i = nodes.length - 1; i >= 0; i--) {
        treeObj.removeNode(nodes[i]);
      }
    },

    //区域值改变
    regionChangeEvent(value, selectedData) {
      let valueLen = value.length;
      let type = 1;
      let code = "0";
      if (valueLen == 1) {
        type = 1;
        code = value[0].toString() + "00";
        this.currentRegionCode = value[0].toString();
        this.currentregionType = type;
        this.currentRegionName = selectedData[0].label;
        //return;
      } else if (valueLen == 2) {
        type = 2;
        code = value[1].toString();
        this.currentRegionCode = code;
        this.currentregionType = type;
        this.currentRegionName = selectedData[1].__label;
        //code="370104";
      }

      this.drawGeometryByCode(code, type);
    },

    // 添加区域结果
    /**tag:region(行政区域 region)   custom（自定义绘制区域ploygon） */
    addAreaResult(tag) {
      let _this = this;
      let regionName = this.currentRegionName; //默认是行政区域
      let customData = {};
      let regionType = 0;

      if (tag == "custom") {
        customData = this.customerRegionList.filter((ele) => {
          return ele.id == _this.customerArea;
        })[0];
        regionName = customData.regionName;
        regionType = 1;
      }

      if (this.regionResultList.includes(regionName)) {
        this.$Message.info("该区域已添加，请查看~");
        return;
      }
      this.regionResultList.push(regionName);

      //currentRegion数据更新
      let tempRegionData = {
        geoType: "",
        geoValue: "",
        code: "",
      };
      if (tag === "region") {
        tempRegionData = {
          geoType: "region",
          geoValue: this.currentRegionCode,
          code: this.currentRegionCode,
        };
      } else {
        tempRegionData = {
          geoType: "polygon",
          geoValue: customData.regionWkt,
          code: customData.regionCode,
        };
      }
      this.currentRegionList.push(tempRegionData);

      if (tag === "custom") {
        this.getRegionResultId();
        this.$Message.success("添加成功");
        return;
      } //自定义区域在绘制的时候已经保存过了 不需要再保存

      //添加关联区域到数据库里
      let path = this.$api.emergencyMonitorApi.addAssociateArea;
      let param = {
        disasterTaskId: this.taskID,
        regionName: regionName,
        regionCode: tempRegionData.code,
        regionType: regionType,
        regionWkt: null, //tag === "custom" ? customData.regionWkt : "",
        taskSource: 10,
      };

      this.http.post(path, param).then((res) => {
        if (res.data.code == 200) {
          //获取区域结果ID
          this.getRegionResultId();
          this.$Message.success("添加成功");
          this.$emit("refreshRegion");
        } else {
          //获取区域结果ID
          this.getRegionResultId();
          this.$Message.error("添加失败");
        }
      });
    },
    //获取区域结果ID
    getRegionResultId() {
      this.regionResultIDList = [];

      //设置查询区域
      let path = this.$api.emergencyMonitorApi.queryAssociateAreaBytaskId;
      let param = {
        taskId: this.taskID,
      };
      this.http.get(path, param).then((res) => {
        if (res.data.code == 200) {
          let regionResultList = res.data.data;
          this.taskAreaList = regionResultList;
          for (let i = 0; i < regionResultList.length; i++) {
            let region = regionResultList[i];
            // 保存ID

            let tempData1 = {
              regionName: region.regionName,
              regionID: region.id,
            };
            this.regionResultIDList.push(tempData1);
          }
        }
      });
    },

    //以下区域结果操作
    async onSelectOption(item, index) {
      let _this = this;
      this.currentSelectRegions = [];
      let obj = {};
      obj.name = item;
      obj.index = index;
      this.currentSelectRegions.push(obj);

      //绘制地图
      this.currentRegionInfo = this.currentRegionList[index];
      if (this.currentRegionInfo.geoType == "region") {
        let regionCode = this.currentRegionInfo.geoValue.toString();
        let code = "";
        let type = "";
        if (regionCode.length == 2) {
          code = regionCode + "0000";
          type = 0;
        } else if (regionCode.length == 4) {
          code = regionCode + "00";
          type = 1;
        } else {
          code = regionCode;
          type = 2;
        }
        this.selectRegionCode = code;
        this.selectRegionWkt = "";
        this.drawGeometryByCode(code, type);
      } else {
        this.selectRegionCode = this.currentRegionInfo.code;
        this.selectRegionWkt = this.currentRegionInfo.geoValue;
        let currentImportantRegions;
        let b = this.currentRegionInfo.geoValue;
        let types = typeof b;

        if (types == "object") {
          currentImportantRegions = b;
        } else {
          currentImportantRegions = wktToGeoJson(b); //await this.wktToGeojson(b);
        }
        this.currentRegionInfo.geoValue = currentImportantRegions;
        let geometry = {};
        if (currentImportantRegions.type == "FeatureCollection") {
          geometry = shpDataRegion.features[0]; //写的有问题 shpDataRegion为无效值
        } else if (currentImportantRegions.type == "Feature") {
          geometry = currentImportantRegions.geometry;
        } else if (currentImportantRegions.type == "Polygon") {
          geometry = currentImportantRegions;
        } else if (currentImportantRegions.type === "MultiPolygon") {
          geometry = currentImportantRegions;
        } else {
          geometry = currentImportantRegions.geometries;
        }
        _this.$emit("drawGeometry", geometry);
      }
    },
    //wkt转Geojson
    async wktToGeojson(wkt) {
      let geojson = "";
      let path = this.$api.emergencyMonitorApi.wktToGeoJson;
      await this.http.post(path, { wkt }).then((res) => {
        if (res.data.success) {
          geojson = res.data.data;
        } else {
          this.$Message.error("geojson转换失败,范围显示失败！");
        }
      });
      return geojson;
    },
    // 删除区域
    regionDel() {
      let options = this.currentSelectRegions;
      if (options[0].index == 0) {
        alert("不可删除首个省市的区域！！！");
        return;
      }
      let regionIDIndex = options[0].index - 1;
      let regionResultId = this.regionResultIDList[regionIDIndex].regionID;
      for (let i = 0; i < options.length; i++) {
        this.regionResultList.splice(options[i].index, 1);
        this.currentRegionList.splice(options[i].index, 1);
        this.regionResultIDList.splice(options[i].index - 1, 1);
      }
      let path = this.$api.emergencyMonitorApi.deleteAssociateArea + `${regionResultId}`;

      this.http.delete(path).then((res) => {
        if (res.data.code == 200) {
          //获取区域结果ID
          this.getRegionResultId();
          this.$Message.success("删除成功");
          this.$emit("removeRegionLayer", "maine");
          this.$emit("refreshRegion");
        } else {
          //获取区域结果ID
          this.getRegionResultId();
          this.$Message.error("删除失败");
        }
      });
    },

    // 以上为区域操作结果

    judgeIsChecked(pName, cName) {
      let content = this.selectInfoList;

      for (let i = 0; i < content.length; i++) {
        if (content[i].satellite == pName) {
          if (cName == "") {
            return true;
          } else {
            for (let j = 0; j < content[i].sensors.length; j++) {
              if (cName != "" && content[i].sensors[j] == cName) {
                return true;
              }
            }
          }
        }
      }

      return false;
    },
    /** 卫星传感器选择 */
    selectAddInfoCancel() {
      this.showSelectAddInfoZtreeModal = false;
      //this.updateShow = true;
    },
    selectAddInfoOk() {
      this.selectInfoList = [];
      //this.flowParamList = [];

      //this.curFlowId = -1;
      //this.curInputParamKey = "";
      //this.curOutputParamKey = "";

      let sateList = [];
      let sensorList = [];

      let treeObj = $.fn.zTree.getZTreeObj("selectInfoTree"),
        nodes = treeObj.getCheckedNodes(true);
      let tempNode = "";

      for (let index in nodes) {
        let isExist = false;
        tempNode = nodes[index];

        if (tempNode.pId != null) {
          for (let tempInfo of this.selectInfoList) {
            if (tempInfo.satellite == tempNode.pId) {
              if (sensorList.indexOf(tempNode.id) == -1) {
                sensorList.push(tempNode.id);
              }

              tempInfo.sensors.push(tempNode.id);
              isExist = true;
            }
          }
          if (isExist == false) {
            let tempInfo2 = {
              satellite: tempNode.pId,
              sensors: [tempNode.id],
            };
            if (sensorList.indexOf(tempNode.id) == -1) {
              sensorList.push(tempNode.id);
            }

            sateList.push(tempNode.pId);
            this.selectInfoList.push(tempInfo2);
          }
        }
      }

      let info = "";
      for (let sate of sateList) {
        if (info == "") {
          info = sate;
        } else {
          info += "," + sate;
        }
      }
      this.satellites = info;

      info = "";
      for (let sensor of sensorList) {
        if (info == "") {
          info = sensor;
        } else {
          info += "," + sensor;
        }
      }
      this.sensors = info;

      this.showSelectAddInfoZtreeModal = false;
      //this.addShow = true;

      //this.getFlowInfoList();
    },
    selectAddInfo() {
      let self = this;

      let setting = {
        check: {
          enable: true,
          nocheckInherit: false,
          checkTypeFlag: true,
          callbackFlag: true,
        },
        data: {
          simpleData: {
            enable: true,
          },
        },
        callback: {
          beforeClick: this.beforeClick,
          onClick: this.zTreeOnClick,
          onCheck: this.zTreeOnCheck,
          onExpand: this.zTreeOnClick,
        },
      };

      let path = this.$api.emergencyMonitorApi.queryRelated;
      let param = {
        pageNum: -1,
        pageSize: -1,
      };

      this.http.get(path, param).then((res) => {
        if (res.data.success) {
          self.showSelectAddInfoZtreeModal = true;
          //self.addShow = false;

          let content = res.data.data;
          let ztreeContent = [];
          let SatelliteNameList = [];
          let tempZtreeInfos = [];

          for (let item of content) {
            //当前卫星节点
            let curSatelliteName = item.satelliteName;

            if (SatelliteNameList.indexOf(curSatelliteName) == -1) {
              let isChecked = self.judgeIsChecked(curSatelliteName, "");
              let node = {
                name: curSatelliteName,
                id: curSatelliteName,
                pId: 0,
                checked: isChecked,
              };
              ztreeContent.push(node);
              SatelliteNameList.push(curSatelliteName);

              let tempInfo = {
                satellite: curSatelliteName,
                sensors: [],
              };
              tempZtreeInfos.push(tempInfo);
            }

            item.sensors.forEach((ele, i) => {
              Object.keys(ele).forEach((tempvalue) => {
                let sensor = item.sensors[i][tempvalue];
                for (let tempInfo of tempZtreeInfos) {
                  if (
                    tempInfo.satellite == curSatelliteName &&
                    tempInfo.sensors.indexOf(sensor) == -1
                  ) {
                    tempInfo.sensors.push(sensor);
                    let isChecked2 = self.judgeIsChecked(curSatelliteName, sensor);

                    let childNode = {
                      name: sensor,
                      id: sensor,
                      pId: item.satelliteName,
                      checked: isChecked2,
                    };
                    ztreeContent.push(childNode);
                  }
                }
              });
            });
          }

          $.fn.zTree.init($("#selectInfoTree"), setting, ztreeContent);
        } else {
          self.$Message.error(res.data.message);
        }
      });
    },
    // 取消
    ProductProductionBtn() {},
    getSearchRegion() {
      let areas = [];

      for (let i = 0; i < this.taskAreaList.length; i++) {
        let areaparam = {};
        let data = this.taskAreaList[i];
        areaparam.geoName = data.regionName;
        areaparam.geoType = data.regionType == 1 ? "polygon" : "region"; //目前两种 0是region 1是polygon（自定义区域） ；注意  后续可能会加shp
        areaparam.geoValue = this.taskAreaList[i].regionCode; //默认是region
        if (data.regionType == 1) {
          areaparam.geoValue = data.regionWkt;
        }
        areas.push(areaparam);
      }

      if (this.taskAreaList.length < 1) {
        //当没有区域选择时把当事件的范围信息传给后端
        let data = this.currentRegionList[0];
        let areaparam = {};
        areaparam.geoName = this.TaskAddress;
        areaparam.geoType = "region";
        areaparam.geoValue = data.geoValue;
        areas.push(areaparam);
      }
      return areas;
    },

    // 保存
    saveEmergencyTask() {
      // 处理区域结果数据   区划+自定义
      let areas = this.getSearchRegion();

      // let geoJson = this.$parent.getCurrentDrawGeometry(); //当前地图绘制范围数据
      let taskStatus = "";
      if (this.disasterTaskStatus == 0) {
        taskStatus = "complete";
      } else {
        taskStatus = "running";
      }

      let params = {
        id: this.taskID,
        disasterId: this.disasterId,
        disasterName: this.TaskDisasterType,
        name: this.taskName,
        occurTime: this.taskTime,
        regionCode: this.regionProviceCode,
        regionName: this.TaskAddress,
        // status: this.disasterTaskStatus,
        status: taskStatus,
        params: {
          level: this.productLevel,
          satellite: this.satellites,
          sensor: this.sensors,
          area: areas,
        },
      };

      let path = this.$api.emergencyMonitorApi.updateEmergencyTask;
      this.http.post(path, params).then((res) => {
        if (res.data.code == 200) {
          this.$Message.success(res.data.message);
          // this.getDisasterInfoById(); //刷新任务数据
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },

    // 数据目录树功能
    //data:当前选中的数据列表 item：勾选的当前项
    getTreeNodeInfo(data, item) {
      this.currentSelectData = data;
      console.log('yuioop',data, item);
      if (item.checked) {
        this.getPublishId.push(item.id);
      } else {
        this.getPublishId = this.getPublishId.filter((ele) => {
          return ele !== item.id;
        });
      }
      console.log(this.getPublishId);
      let dataNote0 = [];
      let dataNote1 = [];
      let nodes = [];
      this.selcetFilePath = [];
      data.forEach((node) => {
        //勾选的叶子节点数据
        if (!node.children) {
          let filePath = node.path + "/" + node.title;
          this.selcetFilePath.push(filePath);
          nodes.push(node);
        }
        //储存勾选的日期父节点数据
        if (node.title.split("-").length == 3) {
          dataNote0.push(node);
        }

        //勾选的等级节点数据
        if (!node.title.includes(".") && node.title.includes("L")) {
          dataNote1.push(node);
        }
        this.nodes = nodes;
        this.dataNote1 = dataNote1;
        this.dataNote0 = dataNote0;
      });
      //this.$emit("updateDir", this.selcetFilePath);
      // this.getTile(nodes);
      this.loadShpAndImg(item, "beforeMap");
    },
    removeLayer(layerID) {
      if (this.map.getLayer(layerID)) {
        this.map.removeLayer(layerID);
      }
      if (this.map.getSource(layerID)) {
        this.map.removeSource(layerID);
      }
      if (this.afterMap.getLayer(layerID)) {
        this.afterMap.removeLayer(layerID);
      }
      if (this.afterMap.getSource(layerID)) {
        this.afterMap.removeSource(layerID);
      }
    },
    //加载树节点数据到地图中
    loadShpAndImg(node, mapDiv) {
      let dataNote0 = this.dataNote0;
      let dataNote1 = this.dataNote1;
      let nodes = this.nodes;
      //当前勾选的是叶子节点
      if (!node.children && node.checked == true) {
        dataNote1.forEach((l) => {
          if (JSON.stringify(l.children).indexOf(JSON.stringify(node)) != -1) {
            dataNote0.forEach((d) => {
              if (JSON.stringify(d.children).indexOf(JSON.stringify(l)) != -1) {
                this.showImg(node, mapDiv);
              }
            });
          }
        });
      } else if (!node.children && node.checked == false) {
        // let imgPath = node.path + "/" + node.title;
        // let layerID = "picture" + imgPath;
        let layerID = "";
        if (
          node.title.includes(".tif") ||
          node.title.includes(".img") ||
          node.title.includes(".jpg")
        ) {
          let imgPath = node.path + "/" + node.title;
          layerID = "picture" + imgPath;
        } else {
          console.log(node, "noed");
          layerID = node.id;
        }
        if (node.checked ? false : true) {
          this.removeLayer(layerID);
        } else if (mapDiv === "afterMap") {
          this.removeLayer(layerID);
        } else if (mapDiv === "beforeMap" && this.map.getLayer(layerID)) {
          this.$Message.info("当前地图已添加该影像，请勿重复加载！");
          return;
        }
      }
      //勾选父节点。
      if (!node.title.includes(".") && node.title.includes("L") && node.checked == true) {
        for (let i = 0; i < nodes.length; i++) {
          console.log(node, "nodechildren");
          console.log(nodes[i], "nodes[i]");
          let a = JSON.stringify(node.children).indexOf(JSON.stringify(nodes[i]));
          console.log(a, "a");
          if (JSON.stringify(node.children).indexOf(JSON.stringify(nodes[i])) != -1) {
            console.log("op");
            dataNote0.forEach((d) => {
              if (JSON.stringify(d.children).indexOf(JSON.stringify(node)) != -1) {
                console.log("lll");
                this.showImg(nodes[i], mapDiv);
              }
            });
          }
        }
      } else if (
        !node.title.includes(".") &&
        node.title.includes("L") &&
        node.checked == false
      ) {
        for (let i = 0; i < nodes.length; i++) {
          if (JSON.stringify(node.children).indexOf(JSON.stringify(nodes[i])) != -1) {
            // let imgPath = nodes[i].path + "/" + nodes[i].title;
            // console.log(nodes.length, "nodeslength");
            // console.log(imgPath);
            // let layerID = "picture" + imgPath;
            let layerID = "";
            if (
              nodes[i].title.includes(".tif") ||
              nodes[i].title.includes(".img") ||
              nodes[i].title.includes(".jpg")
            ) {
              let imgPath = nodes[i].path + "/" + nodes[i].title;
              layerID = "picture" + imgPath;
            } else {
              layerID = nodes[i].id;
              console.log(nodes, "node");
            }
            if (nodes[i].checked ? true : false) {
              this.removeLayer(layerID);
            } else if (mapDiv === "afterMap") {
              this.removeLayer(layerID);
            } else if (mapDiv === "beforeMap" && this.map.getLayer(layerID)) {
              return;
            }
          }
        }
        // for(let i=0;i<node.children.length;i++){
        //   let imgPath = node.children[i].path + "/" +node.children[i].title;
        //   console.log(imgPath,"io")
        //   let layerID = "picture" + imgPath;
        //   if (node.children[i].checked ? true :false ) {
        //     this.removeLayer(layerID);
        //     return;
        //   } else if (mapDiv === "afterMap") {
        //     this.removeLayer(layerID);
        //   } else if (mapDiv === "beforeMap" && this.map.getLayer(layerID)) {
        //     return;
        //   }}
      }
      //勾选日期节点
      if (node.title.split("-").length == 3 && node.checked === true) {
        console.log(node, "nodeo");
        for (let i = 0; i < dataNote1.length; i++) {
          let b = JSON.stringify(node.children).indexOf(JSON.stringify(dataNote1[i]));
          console.log(b, "b");
          if (JSON.stringify(node.children).indexOf(JSON.stringify(dataNote1[i])) != -1) {
            console.log(node, "node1");
            for (let j = 0; j < nodes.length; j++) {
              if (
                JSON.stringify(dataNote1[i].children).indexOf(JSON.stringify(nodes[j])) !=
                -1
              ) {
                console.log("zuihou ");
                this.showImg(nodes[j], mapDiv);
              }
            }
          }
        }
        // dataNote1.forEach((l) => {
        //     if(JSON.stringify(node.children).indexOf(JSON.stringify(l))){
        //         for(let i=0;i<nodes.length;i++){
        //             if(JSON.stringify(l).indexOf(JSON.stringify(nodes[i]))){
        //               this.showImg(nodes[i],mapDiv)
        //             }}}
        // })
      } else if (node.title.split("-").length == 3 && node.checked == false) {
        for (let i = 0; i < node.children.length; i++) {
          for (let j = 0; j < node.children[i].children.length; j++) {
            // let imgPath =
            //   node.children[i].children[j].path +
            //   "/" +
            //   node.children[i].children[j].title;
            // let layerID = "picture" + imgPath;
            let layerID = "";
            console.log(node);
            if (
              node.children[i].children[j].title.includes(".tif") ||
              node.children[i].children[j].title.includes(".img") ||
              node.children[i].children[j].title.includes(".jpg")
            ) {
              let imgPath =
                node.children[i].children[j].path +
                "/" +
                node.children[i].children[j].title;
              layerID = "picture" + imgPath;
            } else {
              layerID = node.children[i].children[j].id;
            }
            if (node.children[i].children[j].checked ? true : false) {
              this.removeLayer(layerID);
            } else if (mapDiv === "afterMap") {
              this.removeLayer(layerID);
            } else if (mapDiv === "beforeMap" && this.map.getLayer(layerID)) {
              return;
            }
          }
        }
      }
    },

    showImg(node, mapDiv) {
      if (node.level.includes("L1") && !node.title.endsWith(".shp")) {
        //  L1A数据加载
        this.getFirstA(node.id, node.checked ? true : false, mapDiv);
      } else if (
        node.region != null &&
        node.level.includes("L2") &&
        !node.title.endsWith(".shp")
      ) {
        // L1A数据加载
        this.getFirstA(node.id, node.checked ? true : false, mapDiv);
      } else if (!node.level.includes("L1") && !node.title.endsWith(".shp")) {
        // 瓦片数据加载
        let path = node.path + "/" + node.title;
        this.getInfo([path], node.checked ? true : false, mapDiv);
      } else if (node.title.endsWith(".shp")) {
        // 矢量数据加载
        this.getRegionByShp(node, node.checked ? true : false);
      }
    },

    //获得切片 //暂时不用 函数loadShpAndImg代替
    getTile(data) {
      console.log(data, "data89");
      let L1aArr = [];
      let tilePathArr = [];
      let shpArr = [];
      if (data.length > 0)
        for (let node of data) {
          console.log(node, "node");
          if (node.level.includes("L1") && !node.title.endsWith(".shp")) {
            L1aArr.push(node.id);
          } else if (
            node.region != null &&
            node.level.includes("L2") &&
            !node.title.endsWith(".shp")
          ) {
            L1aArr.push(node.id);
          } else if (!node.level.includes("L1") && !node.title.endsWith(".shp")) {
            tilePathArr.push(node.path + "/" + node.title);
          } else if (node.title.endsWith(".shp")) {
            shpArr.push(node);
          }
        }
      this.selectTileData = tilePathArr;
      //----L1A数据加载---------------
      let temp3 = this.getTreeNodeOfOperation(L1aArr, this.lastX1);
      if (temp3.path.length > 0) this.getFirstA(temp3.path[0], temp3.isShow);
      this.lastX1 = L1aArr;
      //------瓦片数据加载-------------
      let temp1 = this.getTreeNodeOfOperation(tilePathArr, this.lastX2);
      console.log(temp1, "temp1");
      if (temp1.path.length > 0) this.getInfo(temp1.path, temp1.isShow);
      this.lastX2 = tilePathArr;
      //------矢量数据加载-------------
      let temp2 = this.getTreeNodeOfOperation(shpArr, this.lastShp);
      if (temp2.path.length > 0) this.getRegionByShp(temp2.path[0], temp2.isShow);
      this.lastShp = shpArr;
    },

    //得到树节点的操作的当前节点的显示还是取消
    /**currentNodeArr: 当前目录树选择的所有符合的树节点;lastNodeArr:上一次目录树选中的树节点*/
    getTreeNodeOfOperation(currentNodeArr, lastNodeArr) {
      let result = {
        path: [],
        isShow: false,
      };
      if (currentNodeArr.length > lastNodeArr.length) {
        //勾选数据
        result.path = currentNodeArr.filter((ele) => {
          return !lastNodeArr.includes(ele);
        });
        result.isShow = true;
      } else if (currentNodeArr.length < lastNodeArr.length) {
        //取消勾选
        result.path = lastNodeArr.filter((ele) => {
          return !currentNodeArr.includes(ele);
        });
        result.isShow = false;getDataTreeList()
      }
      return result;
    },
    // 右键查看元数据样式
    handleContextMenu(data) {
      console.log(data, "data123");
      this.currentTreeNode = data;
    },
    // 元数据查看
    async metadataView() {
      const path =
        this.$api.emergencyMonitorApi.queryDataWithId + this.currentTreeNode.id;
      const { data } = await axios.get(path);
      console.log("元数据查看",data)
      // let data = {
      //           "message": "查询成功",
      //           "success": true,
      //           "code": 200,
      //           "data": {
      //               "id": 26129,
      //               "taskId": 384,
      //               "dataId": null,
      //               "name": "HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HV_L4_0000102553.tif",
      //               "path": "/pie/data/wx01wxyg102/01/Disaster/2023-06-20-江苏省-洪涝/2023-09-10/L4/HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HHHV_L4_0000102553",
      //               "meta": "<?xml version='1.0' encoding='UTF-8'?><ProductMetaData> <SatelliteID></SatelliteID> <SensorID></SensorID> <ReceiveTime>NULL</ReceiveTime> <OrbitID></OrbitID> <ProductFormat>GEOTIFF</ProductFormat> <ProductTime>2023-09-10 09:13:36</ProductTime> <ProductLevel>LEVEL4</ProductLevel> <ImageGSD>5</ImageGSD> <CloudPercent></CloudPercent> <DetectCloudPercent></DetectCloudPercent> <WidthInPixels>10864</WidthInPixels> <HeightInPixels>10164</HeightInPixels> <TopLeftLatitude>31.227</TopLeftLatitude> <TopLeftLongitude>119.752</TopLeftLongitude> <TopRightLatitude>31.1387</TopRightLatitude> <TopRightLongitude>120.181</TopRightLongitude> <BottomLeftLatitude>30.8068</BottomLeftLatitude> <BottomLeftLongitude>119.638</BottomLeftLongitude> <BottomRightLatitude>30.7189</BottomRightLatitude> <BottomRightLongitude>120.065</BottomRightLongitude> <Projectioninfomation></Projectioninfomation> <Spatialreference>GCS_WGS_1984</Spatialreference> <SceneID>113036</SceneID> <ProductID></ProductID> <ScenePath></ScenePath> <SceneRow></SceneRow> <SatPath></SatPath> <SatRow></SatRow> <CenterTime></CenterTime> <ProductUnit>应急管理部国家减灾中心</ProductUnit> <ProductName>HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HV_L10000102553_MultiAmp_ortho.tif</ProductName> <Producer></Producer> <ProductDepart></ProductDepart> <QualityChecker></QualityChecker> <QCDepart></QCDepart> <QCTime></QCTime> <AreaInfo></AreaInfo> <AreaType></AreaType> <AreaNumber></AreaNumber> <ProductTask></ProductTask> <ImageExtent>119.638,31.2271|120.181,31.2271|120.181,30.7189|119.638,30.7189</ImageExtent></ProductMetaData>",
      //               "thumb": "http://172.17.102.36:30800/sthx_server/product/taskProduct/png/view?path=/pie/data/wx01wxyg102/01/Disaster/2023-06-20-江苏省-洪涝/2023-09-10/L4/HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HHHV_L4_0000102553/HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HV_L4_0000102553_thumb.jpg",
      //               "region": "POLYGON((119.752 31.227,119.638 30.8068,120.065 30.7189,120.181 31.1387,119.752 31.227))",
      //               "level": "L4",
      //               "status": "normal",
      //               "produceTime": "2023-09-09 00:00:00",
      //               "createTime": "2023-09-10 00:55:48",
      //               "dataType": null,
      //               "sensor": null
      //           },
      //           "total": -1
      //     };
      /**
        * {
                "message": "查询成功",
                "success": true,
                "code": 200,
                "data": {
                    "id": 26129,
                    "taskId": 384,
                    "dataId": null,
                    "name": "HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HV_L4_0000102553.tif",
                    "path": "/pie/data/wx01wxyg102/01/Disaster/2023-06-20-江苏省-洪涝/2023-09-10/L4/HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HHHV_L4_0000102553",
                    "meta": "<?xml version='1.0' encoding='UTF-8'?><ProductMetaData> <SatelliteID></SatelliteID> <SensorID></SensorID> <ReceiveTime>NULL</ReceiveTime> <OrbitID></OrbitID> <ProductFormat>GEOTIFF</ProductFormat> <ProductTime>2023-09-10 09:13:36</ProductTime> <ProductLevel>LEVEL4</ProductLevel> <ImageGSD>5</ImageGSD> <CloudPercent></CloudPercent> <DetectCloudPercent></DetectCloudPercent> <WidthInPixels>10864</WidthInPixels> <HeightInPixels>10164</HeightInPixels> <TopLeftLatitude>31.227</TopLeftLatitude> <TopLeftLongitude>119.752</TopLeftLongitude> <TopRightLatitude>31.1387</TopRightLatitude> <TopRightLongitude>120.181</TopRightLongitude> <BottomLeftLatitude>30.8068</BottomLeftLatitude> <BottomLeftLongitude>119.638</BottomLeftLongitude> <BottomRightLatitude>30.7189</BottomRightLatitude> <BottomRightLongitude>120.065</BottomRightLongitude> <Projectioninfomation></Projectioninfomation> <Spatialreference>GCS_WGS_1984</Spatialreference> <SceneID>113036</SceneID> <ProductID></ProductID> <ScenePath></ScenePath> <SceneRow></SceneRow> <SatPath></SatPath> <SatRow></SatRow> <CenterTime></CenterTime> <ProductUnit>应急管理部国家减灾中心</ProductUnit> <ProductName>HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HV_L10000102553_MultiAmp_ortho.tif</ProductName> <Producer></Producer> <ProductDepart></ProductDepart> <QualityChecker></QualityChecker> <QCDepart></QCDepart> <QCTime></QCTime> <AreaInfo></AreaInfo> <AreaType></AreaType> <AreaNumber></AreaNumber> <ProductTask></ProductTask> <ImageExtent>119.638,31.2271|120.181,31.2271|120.181,30.7189|119.638,30.7189</ImageExtent></ProductMetaData>",
                    "thumb": "http://172.17.102.36:30800/sthx_server/product/taskProduct/png/view?path=/pie/data/wx01wxyg102/01/Disaster/2023-06-20-江苏省-洪涝/2023-09-10/L4/HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HHHV_L4_0000102553/HJ2E_KSC_STRIP_005056_E119.7_N31.2_20230909_SLC_HV_L4_0000102553_thumb.jpg",
                    "region": "POLYGON((119.752 31.227,119.638 30.8068,120.065 30.7189,120.181 31.1387,119.752 31.227))",
                    "level": "L4",
                    "status": "normal",
                    "produceTime": "2023-09-09 00:00:00",
                    "createTime": "2023-09-10 00:55:48",
                    "dataType": null,
                    "sensor": null
                },
                "total": -1
          }
       * 
       * 
       * 
       *       
       **/ 
      if (!data.success) {
        this.$Message.error("查询元数据失败");
        return;
      }
      this.imgDetails = data.data;
      // let meta = JSON.parseObject(data.data.meta);
      //  let x=XML.toJSONObject(data.data.meta);
      //  let c=XML.toString(x);

      //var x2js = new X2JS(data.data.meta);
      if (data.data.meta) {
        this.dataMeta = this.$x2js.xml2js(data.data.meta); //xml为需要转换的字符串xml
        console.log("this.dataMeta",this.dataMeta);
        this.dataMeta = this.dataMeta.ProductMetaData;        
        let imgReceiveTime = "";
        if(this.dataMeta.ReceiveTime!="NULL"){
          imgReceiveTime=this.dataMeta.ReceiveTime
        }else{
          let currentTime =  Date.parse(new Date())
          imgReceiveTime=this.timestampToTime(currentTime/1000);          
          // console.log("整理时间戳",currentTime)
        }
        // let imgReceiveTime="2000-4-30 18:23:23";
        //  console.log(imgReceiveTime)
        if (this.dataMeta.SatelliteID != "GF4") {
          // console.log("111111111111111111111",this.dataMeta)
          imgReceiveTime = imgReceiveTime.trim().split(/\s+/);
          // console.log("imgReceiveTime",imgReceiveTime)
          // console.log("imgReceiveTime[0]",imgReceiveTime[0])
          // console.log("imgReceiveTime[1]",imgReceiveTime[1])
          let day =[];
          let hour = [];
          // 判断imgReceiveTime数组元素是否全部都存在
          if(imgReceiveTime.length>=2){
            day = imgReceiveTime[0].trim().split("-");
            hour = imgReceiveTime[1].trim().split(":");
          }
          // let day = imgReceiveTime[0].trim().split("-");
          // let hour = imgReceiveTime[1].trim().split(":");
          let time = Number(hour[0]) + 8;
          let years = Number(day[0]);
          if (time > 23) {
            day[2] = Number(day[2]) + 1;
            time = time - 24;
            day[1] = Number(day[1]);
            if (day[2] === 29) {
              if (day[1] === 2) {
                if (years % 100 === 0 && years % 400 === 0) {
                  day[2] = day[2];
                } else if (years % 100 != 0 && years % 4 === 0) {
                  day[2] = day[2];
                } else {
                  day[1] = 3;
                  day[2] = 1;
                }
              } else {
                day[1] = day[1];
              }
            } else if (day[2] === 30) {
              if (day[1] != 2) {
                day[1] = day[1];
                day[2] = day[2];
              } else {
                day[1] = day[1] + 1;
                day[2] = 1;
              }
            } else if (day[2] === 31) {
              if (day[1] === 4 || day[1] === 6 || day[1] === 9 || day[1] === 11) {
                day[1] = day[1] + 1;
                day[2] = day[2] - 30;
              } else {
                day[2] = day[2];
              }
            } else if (day[2] === 32) {
              if (day[1] != 12) {
                day[1] = day[1] + 1;
                day[2] = day[2] - 31;
              } else {
                day[1] = 1;
                day[2] = day[2] - 31;
                day[0] = Number(day[0]) + 1;
              }
            }
          }
          if (day[1] < 10) day[1] = day[1];
          if (day[2] < 10) day[2] = "0" + day[2];
          imgReceiveTime =
            day[0] +
            "-" +
            day[1] +
            "-" +
            day[2] +
            " " +
            time +
            ":" +
            hour[1] +
            ":" +
            hour[2];
          this.imgReceiveTime = imgReceiveTime;
        } else {
          this.imgReceiveTime = imgReceiveTime;
        }
        // console.log(this.imgReceiveTime,"doble")
        this.metadataViewShow = true;
      } else {
        this.metadataViewShow = false;
        this.$Message.error("无元数据信息");
      }
    },
    //格式化时间
    timestampToTime(timestamp) {
        var date = "";
        //时间戳为10位需*1000，时间戳为13位的话不需乘1000
        if(timestamp.length!=13){
          date =new Date(timestamp * 1000)
        }else{
          date =new Date(timestamp)
        }
        var Y = date.getFullYear() + '-';
        var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
        var D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
        var h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
        var m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
        var s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
        return Y+M+D+h+m+s;
    },
    // 添加
    addTreeData() {
      let _this = this;
      this.fileCatalogModal = true; // 打开弹框
      this.addFileLevelModal = false;
      this.$nextTick(() => {
        _this.$refs.refFileCatalogModal.initFileTree(
          {
            type: { name: "file" },
            constraint: { extensions: "*.zip,*.tar.gz" },
          },
          false
        );
        _this.$refs.refFileCatalogModal.handleShow(true);
      });
    },

    // 移除
    deleteTreeData() {
      this.delShow = true;
    },
    //确定移除
    delTreeDataOk() {
      this.delShow = false;
      let arr = []; //记录移除节点的id
      let i = 0;
      console.log(this.nodes, "nodes");
      while (i < this.nodes.length) {
        if (this.nodes[i].id) {
          arr.push(this.nodes[i].id);
        }
        i++;
      }
      let nodes = this.nodes;
      let path = this.$api.emergencyMonitorApi.updateAssociateDataBatch;
      // let flag = 0;
      let param = [];
      for (let i = 0; i < arr.length; i++) {
        let temp = {
          id: arr[i],
          status: "delete",
        };
        param.push(temp);
      }
      console.log(param, "param");
      this.http.post(path, param).then((res) => {
        if (res.data.code == 200) {
          // flag++;
          this.$Message.info("移除成功，即将刷新目录树！");
          this.getTreeDataList();
        } else {
          this.$Message.error(res.data.message);
        }
      });

      // if (flag == arr.length) {
      //   this.$Message.success("移除成功！");
      // } else if (flag == 0) {
      //   this.$Message.error("移除失败！");
      // } else {
      //   this.$Message.error("部分移除失败！");
      // }
    },

    // 数据恢复
    recoverTreeData() {
      this.recoverShow = true;
      let path = this.$api.emergencyMonitorApi.queryAssociateData;
      let param = {
        taskId: this.taskID,
        status: "delete",
      };
      this.http.get(path, param).then((res) => {
        if (res.data.code == 200) {
          this.recoverData = res.data.data;
        } else {
          this.recoverData = [];
        }
      });
    },
    //发布
    publish() {
      // 勾选错误数据
      // 1.存在其他数据
      // 2.全是其他数据
      let exitArray = []; //存入数据
      let noExitArray = []; //存入数据
      this.productTypeValue = "";
      this.currentSelectData.map((item) => {
        console.log("当前勾选数据：", item);
        if (item.path) {
          if (item.path.indexOf("L5") != -1 || item.path.indexOf("L6") != -1) {
            exitArray.push(1);
          } else if (item.path.indexOf("L4") != -1) {
            exitArray.push(2);
          } else {
            console.log("...");
          }
          if (
            item.path.indexOf("L5") == -1 &&
            item.path.indexOf("L6") == -1 &&
            item.path.indexOf("L4") == -1
          ) {
            noExitArray.push(item);
          }
        } else {
          this.$Message.info("不支持该级别数据的发布");
          return false;
        }
      });
      let noRepeatArray = [...new Set(exitArray)];
      console.log("去重后的数据：", noRepeatArray);
      if (this.currentSelectData.length != 0) {
        // 判断多种数据同时存在
        if (this.currentSelectData.length == exitArray.length) {
          if (exitArray.length != 1 && exitArray.length == noRepeatArray.length) {
            this.$Message.info("需要选择同类型数据发布");
            return false;
          }
        }
        // 判断多种数据同时不存在
        if (noExitArray.length > 0) {
          this.$Message.info("存在不支持发布的数据类型");
          return false;
        }
      } else {
        this.$Message.info("请勾选要发布的数据");
        return false;
      }
      // 勾选了正确数据：L4 L5 L6
      let pushArray = [];
      let L4Array = [];
      this.currentSelectData.map((item) => {
        console.log("当前勾选数据：", item);
        if (item.path) {
          if (item.path.indexOf("L5") != -1 || item.path.indexOf("L6") != -1) {
            console.log("存在5,6数据：", item);
            pushArray.push(item);
          }

          if (item.path.indexOf("L4") != -1) {
            console.log("存在4数据：", item);
            L4Array.push(item);
          }
        }
      });
      // 相同
      if (
        this.currentSelectData.length != 0 &&
        this.currentSelectData.length == pushArray.length
      ) {
        console.log("当前勾选数据：", 1);
        this.isShowFbLine = "2";
        // if (this.typeText === '事件') {
          this.productTypeList = [{ label: "卫星应用产品", value: "DISASTER_TOPIC" }];
          this.producesType = [
            {
              value: "1",
              label: "推送实体数据",
            },
            {
              value: "2",
              label: "发布WMTS服务",
            },
          ];
        // } else {
        //   this.productTypeList = [{ label: "监测数据", value: "RISK_DATA" }];
        //   this.producesType = [
        //     {
        //       value: "1",
        //       label: "推送实体数据",
        //     }
        //   ];
        //   // 如果只有一个方式，默认选中它
        //   this.selectDataTypeFb = '2';
        // }
        
      } else if (
        this.currentSelectData.length != 0 &&
        this.currentSelectData.length == L4Array.length
      ) {
        console.log("当前勾选数据：", 2);
        this.isShowFbLine = "1";
        // if (this.typeText === '事件') {
          this.productTypeList = [
            { label: "灾前影像", value: "BEFORE" },
            { label: "灾后影像", value: "AFTER" },
          ];
          this.producesType = [
            {
              value: "2",
              label: "发布WMTS服务",
            },
          ];
        // } else {
        //   this.productTypeList = [
        //     { label: "监测数据", value: "RISK_DATA" },
        //   ];
        //   this.producesType = [
        //     {
        //       value: "2",
        //       label: "发布WMTS服务",
        //     },
        //   ];
        // }
        
        // 如果只有一个方式，默认选中它
        this.selectDataTypeFb = '2';
      } else {
        console.log("当前勾选数据：", 3);
        this.producesType = [];
        this.isShowFbLine = "3";
        this.$Message.info("不支持该级别数据的发布");
        return false;
      }

      this.publishShow = true;
      this.getEventName();
    },
    getEventName(val) {
      // console.log('eventDate',this.$moment(this.eventDate).format("YYYY-MM-DD"))
      if (!this.eventType && val !== 'eventType') {
        this.$Message.info("灾害类型为必选项，请先选择灾害类型");
        return;
      }
      let params = {
        eventType: this.eventType,
        eventTitle: this.eventTitle,
        startDate: this.eventDate ? this.$moment(this.eventDate).format("YYYY-MM-DD") : "",
        endDate: this.eventDate ? this.$moment(this.eventDate).format("YYYY-MM-DD") : "",
        provinceId: this.eventArea[0] ? this.eventArea[0] + "0000" : "",
        cityId: this.eventArea[1] ? this.eventArea[1] + "00" : "",
        countyId: this.eventArea[2] ? this.eventArea[2] : "",
      }
      let path = this.$api.emergencyMonitorApi.getEventName;
      this.eventNameList = [];
      this.http.get(path,params).then((res) => {
        console.log('res.data',res.data);
        if (res.data.success) {
          let result = res.data.data;
          this.eventTypeResult = result;
          result.forEach((item) => {
            let obj = {
              label: item.eventTitle,
              value: item.disasterEventId,
            };
            if (!(item.eventTitle.indexOf('日-') > -1)) {
              obj.label = item.eventTime.split('-')[0] + '年' + item.eventTime.split('-')[1] + '月' + item.eventTime.split('-')[2] + '日' + item.eventTitle;
            }
            this.eventNameList.push(obj);
          });
        }
      });
    },
    getEventId(val) {
      let temp = this.eventNameList.find((item) => {
        return item.value === val;
      });
      this.eventId = temp.value;
      this.eventName = temp.label;
    },
    getIamgeName(val) {
      console.log(val);
      this.productType = val.label;
      console.log(this.productType);
      if (val.value == "AFTER" || val.value == "BEFORE") {
        this.isShowFbLineType = "1";
      } else if (val.value == "DISASTER_TOPIC") {
        this.isShowFbLineType = "2";
      } else if (val.value == "RISK_DATA") {
        this.isShowFbLineType = this.isShowFbLine;
      } else {
        this.isShowFbLineType = "3";
      }
      let temp = [];
      console.log(this.eventTypeResult);
      for (let i = 0; i < this.eventTypeResult.length; i++) {
        if (this.eventTypeResult[i].images !== null) {
          console.log(this.eventTypeResult[i].images);
          for (let j = 0; j < this.eventTypeResult[i].images.length; j++) {
            if (this.eventTypeResult[i].images[j].type === val.value) {
              temp.push(this.eventTypeResult[i].images[j]);
            }
          }
        }
      }
      this.imageNameList = [];
      temp.forEach((item, index) => {
        let obj = {
          index: index,
          imageName: item.imageName,
        };
        this.imageNameList.push(obj);
      });
      console.log(this.imageNameList);
    },
    changePage(index) {
      this.pageSelected = index - 1;
    },
    async publishEvent() {
      if (!this.eventId || !this.productTypeValue) {
        this.$Message.info("请先选择事件名称和产品类型");
        return;
      }
      let images = [];
      for (let i = 0; i < this.getPublishId.length; i++) {
        let path = this.$api.emergencyMonitorApi.queryDataWithId + this.getPublishId[i];
        await this.http.get(path).then((res) => {
          console.log(res);
          if (res.data.success) {
            images.push(res.data.data);
          }
        });
      }
      let path = this.$api.emergencyMonitorApi.publinshEvnet;
      let params = {
        eventId: this.eventId,
        eventName: this.eventName,
        images: images,
        taskId: this.taskID,
        type: this.productType,
      };
      if (this.selectDataTypeFb) {
        if (this.selectDataTypeFb == "1") {
          params["isUrl"] = false;
        } else if (this.selectDataTypeFb == "2") {
          params["isUrl"] = true;
        } else {
          params["isUrl"] = false;
        }
      }
      console.log(params);
      this.http.post(path, params).then((res) => {
        this.$Message.info(res.data.message);
      });
      this.$emit("publish");
      this.publishShow = false;
      this.eventType = "FOREST_STEPPE_FIRE";
      this.eventId = "";
      this.productTypeValue = "";
      this.imageNameList = [];
      this.eventDate = "";
      this.eventTitle = "";
      this.eventArea = "";
    },
    publishCanncel() {
      this.publishShow = false;
      this.eventType = "FOREST_STEPPE_FIRE";
      this.eventId = "";
      this.productTypeValue = "";
      this.imageNameList = [];
      this.eventDate = "";
      this.eventTitle = "";
      this.eventArea = "";
    },
    async recoverDataOk() {
      this.recoverShow = false;
      let flag = 0;
      let path = this.$api.emergencyMonitorApi.updateAssociateData;
      for (let i = 0; i < this.recoverNodeList.length; i++) {
        let param = {
          id: this.recoverNodeList[i].id,
          status: "normal",
        };
        await this.http.post(path, param).then((res) => {
          if (res.data.code == 200) {
            flag++;
          } else {
          }
        });
      }
      if (flag == this.recoverNodeList.length) {
        this.$Message.success("恢复成功！");
        this.getTreeDataList();
      } else if (flag == 0) {
        this.$Message.error("恢复失败！");
        this.getTreeDataList();
      } else {
        this.$Message.error("部分恢复失败！");
        this.getTreeDataList();
      }
    },
    selectedData(selection) {
      this.recoverNodeList = selection;
    },

    // 下载
    async downloadTreeData() {
      let path = this.$api.emergencyMonitorApi.queryFiles;
      let param = [];
      // param.push({
      //   excludeFilter: "",
      //   includeFilter: "",
      //   path: "",
      //   suffixFilter: "",
      // });
      console.log("00");
      this.selcetFilePath.forEach((ele) => {
        let folder = ele.substring(0, ele.lastIndexOf("/"));
        let index = param.filter((m) => {
          return m.path == folder;
        });
        if (index.length < 1) param.push({ path: folder });
      });

      let filePathList = [];
      await this.http.post(path, param).then((res) => {
        if (res.data.success) {
          for (var item in res.data.data) {
            filePathList = [...filePathList, ...res.data.data[item]];
          }
        }
      });
      let url = this.$api.processingApi.downloadReport + filePathList;
      window.open(url);
    },
  },
};
</script>
<style lang="scss">
.el-cascader-panel .el-radio__inner {
  width: 100%;
  height: 100%;
  z-index: 10;
  position: absolute;
  top: 10px;
  right: -10px;

}

.el-cascader-panel .el-radio__input.is-checked .el-radio__inner {
    display: none;
}
.pubulishSetting .el-input--medium .el-input__inner {
  height: 30px;
  line-height: 30px;
}
#leftInner {
  margin: 0 20px;
  height: calc(100vh - 267px);
}

#leftInner .iconBtn {
  height: 1.2em !important;
}

#leftInner .iconBtn:hover {
  opacity: 1 !important;
}

#leftInner .iconBtn.delete:hover {
  opacity: 0.8 !important;
}

#leftInner .tab-header {
  font-size: 1.2em;
  color: #5290e8;
  font-weight: bold;
  margin: 6px 0;
}

#leftInner .topBtnGroup {
  display: flex;
  position: relative;

  color: #5290e8;
}

#leftInner .topBtnGroup button {
  flex: 1;
  border: none;
}

#leftInner .topBtnGroup button:hover {
  border-bottom: 1px solid #5290e8;
}

#leftInner .topBtnGroup img {
  box-sizing: unset;

  position: absolute;
  top: -10px;
  right: -35px;
  height: 40px !important;
  border-radius: 50%;
  z-index: 3;
}

#taskDescription div,
#samePeriod div {
  display: flex;
  align-items: center;
  margin-top: 5px;
}

#taskDescription span,
#samePeriod span {
  display: inline-block;
  width: 80px;
  text-align: right;
  color: #666666;
}

#taskDescription .ivu-input-wrapper,
#samePeriod .ivu-input-wrapper {
  flex: 1;
  margin-left: 20px;
}

#spatialRegion .tab {
  background-color: #e3f1ff;
}

#spatialRegion .btnGroup,
#spatialRegion .regionBlock {
  display: flex;
}

// TODO: need to add a focus class if selected
#spatialRegion .btnGroup button {
  flex: 1;
  box-sizing: border-box;
  border: none;
  padding: 4px;
  text-align: center;
  color: black;
  background-color: transparent;
  height: 40px;
}

#spatialRegion .btnGroup button.focus,
#spatialRegion .btnGroup button:hover {
  color: #5290e8;
  border-bottom: 1px solid #5290e8;
}

#spatialRegion .regionBlock {
  align-items: center;
}

#spatialRegion .regionBlock div,
#spatialRegion .regionBlock button {
  margin: 4px;
}

#spatialRegion .regionBlock div {
  flex: 1;
}

#spatialRegion .regionBlock button {
  margin: 0 10px;
  width: 60px;
  height: 100%;
}

#regionResult select {
  width: 100%;
}

#samePeriod .chooseArea {
  margin: 10px 0;
}

#sensorChoose button {
  padding: 0 10px;
  height: 100%;
  margin-left: 10px;
}

#samePeriod div {
  margin-bottom: 6px;
}

#samePeriod div .ivu-input-wrapper {
  width: 80%;
}

#productLevel {
  margin-bottom: 10px;
}

#leftDrawer #closeBtn {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
}
#leftDrawer Tree {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
}

#leftInner .formBtnGroup {
  display: flex;
  justify-content: center;
}

#leftInner .formBtnGroup button {
  margin-top: 20px;
  margin: 8px;
}

#treeData {
  margin-top: 20px;
  width: 100%;
  height: 100%;
  overflow: auto;
}

#treeData .btnGroup {
  display: flex;
  // flex-wrap: wrap;
  justify-content: space-between;
  width: 240px;
  position: absolute;
  margin-left: 10px;
  // margin-left: -20px;
  bottom: 80px;
}

#treeData .publish {
  display: flex;
  justify-content: space-between;
  width: 240px;
  position: absolute;
  margin-left: 13px;
  // margin-right: 2px;
  bottom: 45px;
}
.pubulishSetting {
  display: flex;
  // flex-direction: column;
  flex-wrap: wrap;
  justify-content: center;
}

.queryBox {
  border: 2px solid #DCDEE2;
  padding: 20px 10px 0px 10px;
  border-radius: 5px;
  margin-bottom: 30px;
}

#treeData .btnGroup button {
  padding: 4px, 8px;
  margin: 4px;
}

#downloadSetting .btnGroup {
  display: flex;

  justify-content: center;
}

#downloadSetting .btnGroup button {
  margin: 20px;
}

#downloadSetting .ivu-input-wrapper {
  display: inline;
}
#modaldata div {
  display: flex;
  flex-direction: column;
  width: 600;
  margin: 0 auto;
}
.dataDetails {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  width: 300;
}

.dataDetails div {
  font-size: 1.2em;
  margin: 8px 0;
  width: 400;
}

.dataDetails td {
  padding: 4px;
  border: 0.1px solid #f5f5f5;
}
.style-choice {
  display: flex;
  height: 200px;
  margin-top: 10px;
  border: solid 0.1px #f5f5f5;
}
.download-text {
  margin-bottom: 20px;
}
.download-content {
  margin-top: 10px;
}
.download-button {
  margin-top: 30px;
}
#styleapply button {
  flex: 1;
  border: none;
  padding: 4px, 4px, 4px, 4px;
  text-align: center;
  width: 120px;
  font-size: 1em;
  margin-left: 10px;
}
.crimson-text {
  font-size: 12px;
}

.stylebutton button {
  margin-top: 15px;
  border: solid 0.2px #f5f5f5;
}
.colorbar_box {
  position: relative;
  line-height: 28px;
  margin-left: 20px;
  .colorbar_ipt {
    width: 83%;
    cursor: pointer;
    border: none;
    padding: 0;
    height: 50px;
  }
  i {
    position: absolute;
    right: 9px;
    top: 7px;
    color: #c0c4cc;
    font-size: 15px;
    margin-left: 20px;
  }
  i.active {
    transform: rotate(-180deg);
    transition: transform 0.3s;
    margin-left: 20px;
  }
  ul,
  li {
    list-style: none;
    margin-left: 20px;
  }
  ul {
    padding: 0;
    margin: 0;
    border: 1px none #ccc;
    width: 90%;
    box-shadow: 2.5 0 8px #dedede;
    height: 115px;
    overflow: auto;
    margin-left: 21px;
    // position: absolute;
    // top: 30px;
    // left: 0;
    // z-index: 2000;
  }
  li {
    height: 22px;
    cursor: pointer;
    // color: black;
    line-height: 22px;
    padding: 0 10px;
    box-shadow: 2.5 0 4px #dedede;
    border-bottom: 1px none #fff;
    margin-left: 21px;
  }
}

.dataManagementModal .ivu-modal-body {
  padding: 0 16px;
}
.deleteManagementModal .ivu-modal-body {
  padding: 0 16px;
}
.ivu-select-single .ivu-select-selection .ivu-select-placeholder {
  line-height: 30px;
}
</style>
